-
December 1st, 2012, 12:13 AM
#1
Data in Datagrid appear and then disappear.
Hello everyone,
I have a vb application which search for records in a table based on another table. The table analysis contain multiple record,the table man_tmp should display records based on the ana_id field. When i run the code I see the records in the datagrid but it disappear instantly.Can anyone help please. Here are my code.thnx.
Dim cn2 As New ADODB.Connection
Dim rs1 As New ADODB.Recordset
Set cn2 = New ADODB.Connection
cn2.ConnectionString = MDI1.txtcn
cn2.Open
rs1.Open "select ana_id from analysis where ana_name = 'analysis1'", cn1, adOpenStatic, adLockPessimistic
Do While Not rs1.EOF
Adodc1.ConnectionString = MDI1.txtcn
Adodc1.CommandType = adCmdText
Adodc1.RecordSource = "select * from man_tmp with(nolock)where description like '%" & rs1.Fields("ana_id") & "%'"
Adodc1.Refresh
Set DataGrid1.DataSource = Adodc1
DataGrid1.Refresh
rc.Text = Adodc1.Recordset.RecordCount
If Not rs1.EOF Then
rs1.MoveNext
End If
Loop
-
December 1st, 2012, 06:58 PM
#2
Re: Data in Datagrid appear and then disappear.
You appear to be reseting the datasource in a loop, no idea why you would do this as only the last one would ever remain long enough to see it and if there where no match to the last one then you may see a blip of data then an empty grid.
You should probably rethink your logic here,
Always use [code][/code] tags when posting code.
-
December 2nd, 2012, 11:55 PM
#3
Re: Data in Datagrid appear and then disappear.
Hi thnks for your reply. You know I have 2 tables. I need to search all record in my first table,i.e the man_tmp table for record that are like a column in another table which is the analysis table. The analysis table contain a column name ana_id where there are multiple rows in it.Can you help me with the code as I am stuck here.Thanks.
-
December 3rd, 2012, 10:42 AM
#4
Re: Data in Datagrid appear and then disappear.
I am not sure what you are trying to do, are you trying to display all records from one table where a column matches a value in another, just one record. Try to explain what you are wanting to do in some detail so as to paint a clear picture for us and then I will see what I can do.
Always use [code][/code] tags when posting code.
Tags for this Thread
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
|