|
-
Apr 30th, 2001, 11:40 AM
#1
Thread Starter
PowerPoster
Populating a DB Grid from a RS
How do I fill a DbGrid with a rs?
-
Apr 30th, 2001, 12:18 PM
#2
Hyperactive Member
are you connecting to your database with a datacontrol or ADO?
VB6.0 SP4
Windows 2000
I'm thinking of a number between
-
Apr 30th, 2001, 12:22 PM
#3
Thread Starter
PowerPoster
-
Apr 30th, 2001, 12:29 PM
#4
Hyperactive Member
here's one method:
Code:
Dim cn As New ADODB.Connection
Dim rs As New ADODB.Recordset
Private Sub Form_Load()
cn.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=C:\path\todb.mdb;Jet OLEDB:Database Password=;User ID=;"
With cmd 'set connection and get records
.ActiveConnection = cn
.CommandType = adCmdText
.CommandText = "Select * from tablename"
.Execute
End With
With rs
.CursorLocation = adUseClient
.LockType = adLockOptimistic
.Open cmd
End With
Set DataGrid1.DataSource = rs
End Sub
there's other methods of course, i had this one open to cut and paste in so it's what i posted
make sure you set a reference to Microsoft Activex Data objects 2.5 library
i took the uid and password out obviously
VB6.0 SP4
Windows 2000
I'm thinking of a number between
-
Apr 30th, 2001, 12:36 PM
#5
Thread Starter
PowerPoster
thank you it works and if ever forget to say thanks it's because I get so wrapped up in what I do I forget.
Thanks
-
Apr 30th, 2001, 12:39 PM
#6
Hyperactive Member
thanks isn't necessary, it is nice occasionally though
VB6.0 SP4
Windows 2000
I'm thinking of a number between
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
|