0

Hi,

I'm already create connection to database with datagridview to view the data. I also create header unbound like this :- STUDENT ID,STUDENT NAME,REMARKS(CHECKBOX).

I need to pull data from database with column SM_STUDENT_ID,SM_STUDENT_NAME then insert under this datagridview column.....how to do that..c.an anyone assist me.....so long to setle it..plzzzz

2
Contributors
1
Reply
2
Views
8 Years
Discussion Span
Last Post by sknake
0

Here is an example of connecting to MSSQL and pulling back a result set:

Imports System.Data.SqlClient

Public Class FormSql

	Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
		Const connStr As String = "Data Source=apex2006sql;Initial Catalog=Leather;Integrated Security=True;"
		Const query As String = "Select Top 30 * From Invoice"
		Dim conn As New SqlConnection(connStr)
		conn.Open()
		Dim cmd As New SqlCommand(query, conn)
		Dim dr As SqlDataReader = cmd.ExecuteReader()
		Dim dt As New DataTable()
		dt.Load(dr)
		cmd.Dispose()
		conn.Close()
		conn.Dispose()
		DataGridView1.DataSource = dt
	End Sub
End Class
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.