How to add selected multiple rows from database into datagridview

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
I have a table named invoicedetails. i want to display the rows with the same invoice no in a datagrid view. i tried out the following code. but it doesnt seem to work. can anyone please help me?
<pre class="prettyprint lang-vb Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

myconnection = New SqlConnection("Data Source=.SQLEXPRESS;AttachDbFilename=C:UsersAdministratordocumentsvisual studio 2010ProjectskankukhkankukhkankukhDB.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True")

myconnection.Open()

sql = "SELECT COUNT(*) FROM invoice WHERE ino =" & TextBox1.Text & ""
adapter = New SqlDataAdapter(sql, myconnection)

adapter.Fill(ds)
myconnection.Close()
InvoicedetailsDataGridView.DataSource = ds.Tables(0)



End Sub[/code]
<br/><hr class="sig shehzi

View the full article
 
Back
Top