|
-
Jul 21st, 2005, 04:01 AM
#1
Thread Starter
Junior Member
datagrid with recordset
hello evrybody
i'm trying to connect a datagrid to a recordset using this code:
VB Code:
Dim WithEvents cn As ADODB.Connection
Dim WithEvents rs As ADODB.Recordset
private sub form_load()
Set rs = New ADODB.Recordset
Set cn = New ADODB.Connection
cn.Open "Provider= Microsoft.Jet.OLEDB.4.0; Data Source=" & App.Path & "/workers.mdb;"
rs.Open "select workers.* from workers", cn, adOpenKeyset, adLockOptimistic
Set DataGrid1.DataSource = rs
DataGrid1.Refresh
end sub
There is no error messege, but the datagrid stays empty.
what could by wrong?
-
Jul 21st, 2005, 07:58 AM
#2
Member
Re: datagrid with recordset
There should be an error message, because you are using a forward slash instead of a backslash in the file to open :
VB Code:
cn.Open "Provider= Microsoft.Jet.OLEDB.4.0; Data Source=" & App.Path & "/workers.mdb;"
Could be you used entered it wrong here, in that case, are you sure there is data in the database?
-
Jul 21st, 2005, 08:37 AM
#3
Thread Starter
Junior Member
Re: datagrid with recordset
well, i don't think this is the problem...
the recordset is working, if I'm to search or disply values in it in any other way, but the datagrid is not responding to this.
thank you anyway
daniel
-
Jul 21st, 2005, 10:07 AM
#4
Re: datagrid with recordset
I believe you need to use Client Side cursor when data binding.
VB Code:
cn.Open "Provider= Microsoft.Jet.OLEDB.4.0; Data Source=" & App.Path & "/workers.mdb;"
rs.CursorLocation = adUseClient
rs.Open "select workers.* from workers", cn, adOpenStatic, adLockOptimistic
-
Jul 21st, 2005, 11:26 AM
#5
Thread Starter
Junior Member
Re: datagrid with recordset
thank you very much! it solved it...
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
|