How to load data from database table and display in datagrid in VB.NET? I know how it is in C#. I am not familiar with vb.net. Any help will be appreciated.
1 Answer
Try the following:-
Imports System.Data.SqlClient
In your event, write:-
Dim con As SqlConnection
Dim ada As New SqlDataAdapter()
Dim ds As New DataSet
con = New SqlConnection("server=localhost;uid=sa;pwd=;database=databasename")
con.Open()
ada = New SqlDataAdapter("Select * from tablename", con)
ada.Fill(ds)
DataGridView1.DataSource = ds.Tables(0)
I think this will solve your problem.
1 Comment
Sukanya
@Sun if my solution helps you to solve your problem, please accept it as your answer by clicking the check sign.
datagridis what? ASP.NET, WinForm or WPF Control?