Simple OLE Question

Algar

Active member
Joined
Jun 17, 2003
Messages
28
Location
Toronto
I am have the following code:
Code:
Dim Conn As OleDb.OleDbConnection
Dim sConn = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & _
		 System.Windows.Forms.Application.ExecutablePath & "\db.mdb"
Conn.ConnectionString = sConn
Conn.Open()

This I figured out on my own just playing with things. Seems like I have created a connection object, set the connection parameters and opened the connection. Now I cant for the life of me find how to create a recordset or query the database at all. These simple functions are what I really need right now, but also if anyone has a website (other then msdn, which has already confused me enough for a lifetime) that covers all these basics it would be greatly appreciated, thank you.
 
The next thing you need is the command that will be executed in the database, something like:
Code:
Dim dbCmd As New OleDb.OleDbCommand("command text goes here", Conn)
First the command that will be executed, like:
Code:
SELECT columnname FROM tablename
And then you provide the connection that will be used.
The next thing you have to do is execute the command. If the command returns results (like the one I showed above) you use the ExecuteReader class to get the data to the OldDBDataReader. If you query doesnt return anything, like a querty that inserts data then you execute the command with the ExecuteNonQuery method.
 
Back
Top