Jump to content
Xtreme .Net Talk

PlausiblyDamp

Administrators
  • Posts

    7016
  • Joined

  • Last visited

Everything posted by PlausiblyDamp

  1. Looks like it could be a problem with the line IDbCommand sel =new OleDbCommand("select * from employees", cnctn); does the cnctn equal a valid object? If not that is probably the problem - even though you've put the code in a try block you haven't got a catch block! If it fails you will still get the unhandled exception message. try changing it to something like the following and see if you get the message box. public void EnumerateEmployees(string fileName) { OleDbConnection cnctn = new OleDbConnection(); cnctn.ConnectionString= "Provider=Microsoft.JET.OLEDB.4.0;data source=" + fileName; IDataReader rdr = null; try { cnctn.Open(); IDbCommand sel =new OleDbCommand("select * from employees", cnctn); rdr = sel.ExecuteReader(); while (rdr.Read()) { System.Console.WriteLine(rdr["Name"] + " "+ rdr["age"]); } } catch { System.Windows.Forms.MessageBox.Show("fluff"); } finally { rdr.Close(); cnctn.Close(); }
  2. try something similar to the following - no promises (not near VS.Net at the moment, if it doesn't work reply and I can try later) While dr.Read For iColumn = 0 To dr.FieldCount - 1 Select Case iColumn Case 0 _HeaderData = _HeaderData & dr.Item(iColumn) Case 2 _HeaderData = _HeaderData & "," Dim tmp As Integer tmp = Integer.Parse(dr.Item(iColumn)) Dim str As String str = tmp.ToString("00000") _HeaderData &= str Case Is > 0 _HeaderData = _HeaderData & "," _HeaderData = _HeaderData & dr.Item(iColumn) End Select Next _HeaderData = _HeaderData & Chr(13) & Chr(10) End While edit forgot about Case 0 ;)
  3. Does the database have a default specified (or a trigger that generates a default value)?
  4. Which of the columns contains the leading zero? You may need to alter the loop to force the format for that particular column. In Excel could you not set the format property of the column to display leading zeros?
  5. What code are you using to write the CSV?
  6. Sounds a bit like a homework question but, firstly how doesn't it work? Errors? invalid results? You are also using a lot of VB6 compatability functions Len, Mid etc Len(text) would be better as text.Length for example. Also CInt(Int((Len(text) * Rnd()) + 1)) seems to be multiplying a long by a single, converting to an integer and then casting that integer to an integer - is that really necessary?
  7. If you remove the end statement does the program close anyway? If not look for places in your code where you are opening other forms and ensure that they are also closed when finished with.
  8. You probably want to look at the classes under System.IO (File, Stream, StreamReader for example) rather than using FileOpen and LineInput.
  9. You will either need to get the web application to impersonate another user (one who does have permissions in the DB) or give the ASPNET account permissions to theDB.
  10. Have you added a variable or property to your mainForm? If so that is the problem.
  11. Is this the only form in the project? If so try letting the form close itself without calling End. If not make sure all the other forms are closed and then allow the main form to just exit normally. End is known to cause problems and is generally considered a bad way to terminate a program - search the forums and you'll find many people suggesting better ways.
  12. Is the sub attempting to update the UI? If so that is probably the problem. UI elements should only be modified from the forms main thread. Search these forums for some examples on using Form.Invoke - not near VS at the moment so I can't dig up the help.
  13. What happens when it runs?
  14. Have you added the Context Menu to the form? If so when it's selected on the form where a menu would normaly go you should see an empty menu bar and the text 'Type here' or similar. Just type the menu items into the list.
  15. You will need either SQL or MSDE installed.
  16. On the toolbox you should have a Context Menu control. Add it to a form and if you click on it you can design the menu like a normal menu. Go to the control you want to have the menu and it shoul have a property called 'Context Menu'. Select the one from the drop down list.
  17. SQL Server uses % Not sure about Access though....
  18. Can't see anything really wrong there - nothing that I would expect to give a NullReferenceException anyway. If you step through the code - what line does it fail on?
  19. There was a post that has since been deleted that was advertising them.
  20. UPDATE table1 SET [GROUP]="none" WHERE IID=0
  21. If you step through the code in the debugger what line of code does it throw the error on? The error means you are trying to reference an object that is set to nothing - could you post some of the relevant code?
  22. If you are using VB.Net there is a set of classes for working with the registry. i.e. Dim regkey As Microsoft.Win32.RegistryKey regkey = Microsoft.Win32.Registry.CurrentUser.OpenSubKey("Software\Microsoft\Command Processor") MessageBox.Show(regkey.GetValue("CompletionChar"))
  23. did you try running the aspnet_regiis.exe /I command I suggested?
  24. Have a look at DataViews in the MSDN - loads of info on them in there.
  25. Dim Jpegs() As String Jpegs = System.IO.Directory.GetFiles("C:\wherever", "*.jpg") ListBox1.datasource = Jpegs
×
×
  • Create New...