|
-
Oct 26th, 2001, 10:25 PM
#1
Thread Starter
Member
Help with Data object please!
How can I open an Access 2000 database using the Data object?
Thanks.
-
Oct 26th, 2001, 10:41 PM
#2
Thread Starter
Member
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.
-
Oct 26th, 2001, 10:46 PM
#3
PowerPoster
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
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
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.
-
Oct 26th, 2001, 10:51 PM
#4
Thread Starter
Member
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
-
Oct 26th, 2001, 11:04 PM
#5
PowerPoster
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
-
Oct 26th, 2001, 11:05 PM
#6
Thread Starter
Member
It's OK.
Thank you SO much!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|