How can I open an Access 2000 database using the Data object?
Thanks.
Printable View
How can I open an Access 2000 database using the Data object?
Thanks.
Please gimme some advice...
If this is not possible using the data object, please tell me another way to use an Access database. I have textbox in which I have to show the content of a field. Any demo or something?
Thanks.
I would recommend using ActiveX data objects. This is Micrsofts
recommended data access solution for connecting to various datastores. Here's an example. Go into Projects --> References
-->Microsoft ActiveX Data Objects...Check it
This only establishes a connection to the database. If you need help retrieving a recordset, let me know. ADO objects are pretty easy to traverse once you get the hang of the object hiearchy.Code:Private Sub Form_Load()
Dim objConn As New ADODB.Connection
Dim strConnectionString As String
strConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Program Files\Microsoft Visual Studio\VB98\NWIND.MDB;Persist Security Info=False"
objConn.Open strConnectionString
End Sub
Thanks. I just want to ask you the following:
I have a multiline textbox and I want to load the contents of the records I have in a field, how can I do it?
I want to use some buttons to move between the fields.
If you can please make a little demo for me, I'll appreciate it a lot. I'm learning, be patient with me ;)
Here's a quick run through on how to navigate thru a recordset. By no means is this complete, just a quick, dirty example.
Code:Option Explicit
Dim objConn As New ADODB.Connection
Dim objRS As New ADODB.Recordset
Private Sub cmdMoveNext_Click()
objRS.MoveNext
If objRS.EOF Then objRS.MovePrevious
End Sub
Private Sub cmdMovePrevious_Click()
objRS.MovePrevious
If objRS.BOF Then objRS.MoveNext
End Sub
Private Sub Form_Load()
Dim strConnectionString As String
strConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Program Files\Microsoft Visual Studio\VB98\NWIND.MDB;Persist Security Info=False"
objConn.Open strConnectionString
objRS.Open "Employees", objConn, adOpenStatic, adLockReadOnly, adCmdTable
Set Text1.DataSource = objRS
Text1.DataField = "EmployeeID"
End Sub
It's OK.
Thank you SO much!