Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Development Tools
 ASP.NET
 Get values method with a datagrid

Author  Topic 

kenone
Starting Member

14 Posts

Posted - 2006-02-23 : 01:09:24
Using VB.NET with SQL Server;
I just want to search records from two tables Parent and Child and then display records on the form fields and data grid controls respectively.I can Load the data successfully using the Fill method.My concern here is how to search and display coresponding child records on the datagrid??I have tried to use getvalues method but got some errors...below is my code

[[CODE]Dim selcom As New SqlCommand()
Dim dr As SqlDataReader
Dim message As String
Dim values As Object()


selcom.Connection = SqlConnection1
selcom.CommandText = "select m.checkno, m.lastname, m.othernames,t.paydate, t.basicpay, t.member_amount, t.employer_amount, t.votecode, t.checkno, from members m inner join transactions t on m.checkno = t.checkno where (m.checkno='" & txtCheckNo.Text & "')"

SqlConnection1.Open()
dr = selcom.ExecuteReader
If dr.Read Then
txtCheckNo.Text = dr.GetValue(0)
txtLName.Text = dr.GetValue(1)
txtFName.Text = dr.GetValue(2)
txtVote.Text = dr.GetValue(3)
DataGrid1.Text = dr.GetValues(values)
[/CODE]
Is there anything wrong with my code???Any other way around to display child records on the data grid?????plz help

MichaelP
Jedi Yak

2489 Posts

Posted - 2006-02-23 : 12:35:04
Give this a read and see if this helps ya.

http://www.upyourasp.net/articles/article.aspx?aid=19

Michael

<Yoda>Use the Search page you must. Find the answer you will. Cursors, path to the Dark Side they are. Avoid them, you must. Use Order By NewID() to get a random record you will.</Yoda>
Go to Top of Page
   

- Advertisement -