Matrix1000
asked on
Define OleDbConnection - what? how? thought it was.
I have a form with 3 lablels on it and one text box and one button.
I have made connections to the database using the Data Connection wizzards so now I have an OleDbDataAdapter, OleDbConnection, and DataSet....not sure if that matters but...
When I use the following code in my VB.NET project it underlines OleDbConnection, OleDbCommand and OleDbDataReader saying "Type OleDbCommand is not defined"
What Do I need to do to define them to get this code to work?
-------------------------- ---------- ---------- ---------- ---------
Dim Connection As OleDbConnection = New OleDbConnection(YourConStr )
Dim Command As OleDbCommand = New OleDbCommand("SELECT SocSecNo FROM CustomerMaster WHERE SocSecNo='" & txtSocNo.Text & "' AND LastActiveDate BETWEEN '" & Now() & "' AND '" & Now() - 5, Connection)
Dim DataReader As OleDbDataReader
Connection.Open()
DataReader = Command.ExecuteReader
If DataReader.Read() Then
'Data Found Display in Labels here
lblFirstName.Text = DataReader("FirstName")
lblLastName.Text = DataReader("LastName")
lblSoc.Text = DataReader("SocSecNo")
Else
'No data for the Particular Social ID
'Either Empty the labels or leave it as it is
lblFirstName.Text = ""
lblLastName.Text = ""
lblSoc.Text = ""
End If
DataReader.Close()
Connection.Close()
-------------------------- ---------- ---------- ---------- ---------- ------
Would this be my connection string (YourConStr)
Me.OleDbConnection1.Connec tionString = "Jet OLEDB:Registry Path=;Data Source=""C:\Program Files\My APP\DlrData.mdb"" & _
";Jet OLEDB:System database=;Jet OLEDB:Global Bulk Transactions=1;Jet OL" & _
"EDB:Don't Copy Locale on Compact=False;User ID=Admin;Provider=""Micros oft.Jet.OL E" & _
"DB.4.0"";Jet OLEDB:Database Locking Mode=0;Jet OLEDB:SFP=False;Jet OLEDB:Encrypt " & _
"Database=False;Jet OLEDB:Create System Database=False;Jet OLEDB:Compact Without " & _
"Replica Repair=False;Jet OLEDB:Global Partial Bulk Ops=2;Mode=Share Deny None;Ex" & _
"tended Properties=;Jet OLEDB:Engine Type=4"
I have made connections to the database using the Data Connection wizzards so now I have an OleDbDataAdapter, OleDbConnection, and DataSet....not sure if that matters but...
When I use the following code in my VB.NET project it underlines OleDbConnection, OleDbCommand and OleDbDataReader saying "Type OleDbCommand is not defined"
What Do I need to do to define them to get this code to work?
--------------------------
Dim Connection As OleDbConnection = New OleDbConnection(YourConStr
Dim Command As OleDbCommand = New OleDbCommand("SELECT SocSecNo FROM CustomerMaster WHERE SocSecNo='" & txtSocNo.Text & "' AND LastActiveDate BETWEEN '" & Now() & "' AND '" & Now() - 5, Connection)
Dim DataReader As OleDbDataReader
Connection.Open()
DataReader = Command.ExecuteReader
If DataReader.Read() Then
'Data Found Display in Labels here
lblFirstName.Text = DataReader("FirstName")
lblLastName.Text = DataReader("LastName")
lblSoc.Text = DataReader("SocSecNo")
Else
'No data for the Particular Social ID
'Either Empty the labels or leave it as it is
lblFirstName.Text = ""
lblLastName.Text = ""
lblSoc.Text = ""
End If
DataReader.Close()
Connection.Close()
--------------------------
Would this be my connection string (YourConStr)
Me.OleDbConnection1.Connec
";Jet OLEDB:System database=;Jet OLEDB:Global Bulk Transactions=1;Jet OL" & _
"EDB:Don't Copy Locale on Compact=False;User ID=Admin;Provider=""Micros
"DB.4.0"";Jet OLEDB:Database Locking Mode=0;Jet OLEDB:SFP=False;Jet OLEDB:Encrypt " & _
"Database=False;Jet OLEDB:Create System Database=False;Jet OLEDB:Compact Without " & _
"Replica Repair=False;Jet OLEDB:Global Partial Bulk Ops=2;Mode=Share Deny None;Ex" & _
"tended Properties=;Jet OLEDB:Engine Type=4"
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.