|
-
Feb 27th, 2007, 05:15 AM
#1
Thread Starter
New Member
ado connection and datagrid error
recorded datas seem on datagrid on the connection in form_load procedure
but when i connected to access database in text1_change procedure ,the datas are not being seemed,what is the problem or the code that ı didnt add?
<code>
(general declerations)
------------------------
Dim con As New ADODB.Connection
Dim rs As New ADODB.Recordset
(form load)
-----------
Set rs = New ADODB.Recordset
rs.Open "select * from abc order by a asc ", con, adOpenKeyset, adLockOptimistic
Set DataGrid1.DataSource = rs
set DataGrid1.Columns(0).Datafield="a"
DataGrid1.Columns(0).Caption="a"
set DataGrid1.Columns(0).Datafield="b"
DataGrid1.Columns(0).Caption="b"
set DataGrid1.Columns(0).Datafield="c"
DataGrid1.Columns(0).Caption="c"
Text1.Text = ""
(text1_change)
--------------
Set rs = New ADODB.Recordset
rs.Open "select * from abc where a like '"& text1.text & "%' order by a asc ", con, adOpenKeyset, adLockOptimistic
Set DataGrid1.DataSource = rs
--------------------------------------------------------------------------
-
Feb 27th, 2007, 06:04 AM
#2
Lively Member
Re: ado connection and datagrid error
Hi,
Try using this code......
Code:
'General Declaration
Dim con As New ADODB.Connection
Dim rs As New ADODB.Recordset
Private Sub Form_Load()
con.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Temp\Temp.mdb;Persist Security Info=False"
rs.CursorLocation = adUseClient
rs.Open "select * from abc order by a asc", con, adOpenDynamic, adLockOptimistic
Set DataGrid1.DataSource = rs
End Sub
Private Sub Text1_Change()
If rs.State = 1 Then rs.Close
rs.Open "select * from abc where a like '"& text1.text & "%' order by a asc ", con, adOpenDynamic, adLockReadOnly
DataGrid1.ClearFields
Set DataGrid1.DataSource = rs
End Sub
This will help u out..
-
Mar 1st, 2007, 03:49 AM
#3
Thread Starter
New Member
Re: ado connection and datagrid error
thanks for your help friend,it is working now.. take care
-
Mar 1st, 2007, 10:17 PM
#4
Lively Member
Re: ado connection and datagrid error
Hi,
Just edit ur post and mark it as [RESOLVED]..
Thanx
Rahul Yadav
If your problem has been solved then please mark the thread [RESOLVED].
If i have helped then please Rate my post 
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
|