sambase
07-21-2008, 04:02 AM
hi,
I am try to use ADO to get a collection of data from my database and place it into an msflexgrid. I used to be able to do it years ago but have not done any VB in a long while. Can someone please tell me where i am going wrong. I'm sure theres a lot of work needed on this code :).
Private Sub Command1_Click()
Dim MyConn As New ADODB.connection
Dim myRecSet As ADODB.Recordset
Dim query As Variant
MyConn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data source=E:\Documents and Settings\Sam\Desktop\sams vb stuff\FLEX\stockfile.mdb"
MyConn.Open
query = "SELECT sName FROM Wines"
Set myRecSet = MyConn.Execute(query)
With MSFlexGrid1
.DataSource = query
MSFlexGrid1.Refresh
End With
End Sub
The error message i recieve is "Object required" and when debugging is highlights:
.DataSource = query
Any suggestions?
Thanks,
Sam
I am try to use ADO to get a collection of data from my database and place it into an msflexgrid. I used to be able to do it years ago but have not done any VB in a long while. Can someone please tell me where i am going wrong. I'm sure theres a lot of work needed on this code :).
Private Sub Command1_Click()
Dim MyConn As New ADODB.connection
Dim myRecSet As ADODB.Recordset
Dim query As Variant
MyConn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data source=E:\Documents and Settings\Sam\Desktop\sams vb stuff\FLEX\stockfile.mdb"
MyConn.Open
query = "SELECT sName FROM Wines"
Set myRecSet = MyConn.Execute(query)
With MSFlexGrid1
.DataSource = query
MSFlexGrid1.Refresh
End With
End Sub
The error message i recieve is "Object required" and when debugging is highlights:
.DataSource = query
Any suggestions?
Thanks,
Sam