hello everyone
i should populate the data from table in to data grid but the code i am using below is not working
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim myconnection As New SqlConnection("server=THEJASVI-PC\SQLEXPRESS;database=emp;uid=sa;pwd=2x12")
myconnection.Open()
ds = New DataSet()
s = "select * from emp_details"
Dim da As New SqlDataAdapter(s, myconnection)
da.Fill(ds, "emp_details")
dgvEmployeedetails.DataSource = ds.DefaultViewManager
End Sub
kindly help me to know the correct code
How to populate data in data grid from table of sql server
1 Answer
Know the answer? Post it. Somebody with the same question will find it here.

Brijesh JalanRank #578 · 4.2K reputationPosted Jul 29, 2010, 1:39 AM EDT
I think this code will help you.
Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Dim myconnection As New SqlConnection("server=THEJASVI-PC\SQLEXPRESS;database=emp;uid=sa;pwd=2x12") myconnection.Open() ds = New DataSet() s = "select * from emp_details" Dim da As New SqlDataAdapter(s, myconnection) da.Fill(ds, "emp_details") Dim Source As gridview1.data = ds.tables(emp_details).defaultview gridview1.datamember = emp_details gridview1.databind() End Sub