Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
OleDbCommands with Parameters
Message
General information
Forum:
ASP.NET
Category:
Web forms
Miscellaneous
Thread ID:
00702958
Message ID:
00703076
Views:
16
Thanks, Cathi; this illustrates the problem I am having.

When I run your code sample in a Visual Studio .NET VB Windows Form, I get the following error message at the line where oSelectCommand.ExecuteReader() is called:

"An unhandled exception of type 'System.NullReferenceException' occurred in system.data.dll

Additional information: Object reference not set to an instance of an object."


Any idea why this is happening?

>Here is some sample code that uses the TestData DBC in VFP7:
>
>
>Dim oConnStr As String = "provider=VFPOLEDB.1 ;data source='c:\program files\microsoft visual foxpro 7\samples\data\testdata.dbc';password='';user id=''"
>
>' Make connection to VFP database
>Dim oConn As New OleDbConnection()
>oConn.ConnectionString = oConnStr
>oConn.Open()
>
>' Create a Command object with select statement
>Dim strSelect As [String] = "SELECT * FROM ORDITEMS WHERE LINE_NO=?"
>Dim oSelectCommand As New OleDbCommand(strSelect, oConn)
>
>' Create and set value of the parameter
>oSelectCommand.Parameters.Add("LINE_NO", 1)
>Dim dr As OleDbDataReader = oSelectCommand.ExecuteReader()
>dr.Read()
>MessageBox.Show(dr(0).ToString())
>
>
>>I'm trying to create a simple web form with an OleDbConnection to a Visual FoxPro 7 database (DBC) using the ADO driver for VFP, and an OleDbCommand with an SQL Select query with one parameter. I want to put the results of the query, which should be a few rows from my table, into a DropDownList. The problem is that I always get an error when the OleDbCommand runs ("Object reference to non-object").
>>
>>In the VFP table, the parameter field is numeric, N(2) to be precise. Visual Studio .NET creates a parameter collection with one input parameter of type Decimal. I can get this to work fine if the parameter field is character.
>>
>>Can somebody please send me an example of working code that executes an OleDbCommand with a parameter against a VFP table, where the parameter field is numeric?
Thomas M. Lamm
Bradbury & Associates
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform