Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Parameterized queries
Message
General information
Forum:
Visual FoxPro
Category:
Visual FoxPro and .NET
Miscellaneous
Thread ID:
00654794
Message ID:
00655559
Views:
25
>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

Try putting the code in a Windows form to see if that makes any difference. I'm wondering if this has something to do with user's rights.
-----------------------------------------

Cathi Gero, CPA
Prenia Software & Consulting Services
Microsoft C# / .NET MVP
Mere Mortals for .NET MVP
cgero@prenia.com
www.prenia.com
Weblog: blogs.prenia.com/cathi
Previous
Reply
Map
View

Click here to load this message in the networking platform