Information générale
Catégorie:
Visual FoxPro et .NET
Hi Cathi,
Thanks for the reply but I tried the code and I still get the same error. Maybe it has to do with my setup, but when I get to the 'myDr = myCommand.ExecuteReader()' line I still get the "Object reference not set to an instance of an object" error message. I'm running Windows 2000 SP2SR1, ran through all of the component updates that were needed and installed everything to the hard disk. After failing to get anywhere, I re-installed MDAC 2.7RTM so I think I have the latest version of the OLEDB driver. Also I don't think I mentioned this, but I'm putting this code in the Load event of a WebForm (if that makes any difference). As I said, the SQL Server version worked perfectly so I think it's a driver problem or a configuration problem but I don't know where else to look. If you have any other ideas I'd appreciate hearing from you.
Bob
PS. If I change the myCommand.CommandText programmatically as :
myCommand.CommandText = "Select * from customer where left(company,1) = '" & "A" & "'"
then it also works.
>Dim MyConn As OleDbConnection = New OleDbConnection()
>MyConn.ConnectionString = "provider=VFPOLEDB.1 ;data source='C:\PROGRAM FILES\MICROSOFT VISUAL FOXPRO 7\SAMPLES\DATA\TESTDATA.DBC';password='';user id=''"
>MyConn.Open()
>Dim myCommand As OleDbCommand = New OleDbCommand("Select * from Customer where left(company,1)=?", MyConn)
>myCommand.Parameters.Add("CompanyStartLetter", OleDbType.Char)
>myCommand.Parameters("CompanyStartLetter").Value = "A"
>Dim myDR As OleDbDataReader
>myDR = myCommand.ExecuteReader()
>Do While myDR.Read()
>Me.ListBox1.Items.Add(myDR("Company"))
>Loop
Précédent
Suivant
Répondre
Voir le fil de ce thread
Voir le fil de ce thread à partir de ce message seulement
Voir tous les messages de ce thread
Voir tous les messages de ce thread à partir de ce message seulement