0

I want to populate my table in datagridview from my access database table
please help...

I'm not just trying to bind the table in access to my datagridview...I want to put the data's in my access database to my table in datagridview

so far this is my code.....

Sub filldatagridview()
Dim conn As OleDb.OleDbConnection = New OleDbConnection(strConnect)
conn.Open()

strsql = "select * from Users"
Dim acscmd As New OleDb.OleDbCommand
acscmd.CommandText = strsql

acscmd.Connection = conn
Dim acsdr As OleDbDataReader = acscmd.ExecuteReader
acsdr.Read()

DataGridView1(1, 1).Value = (acsdr("Login_Username"))

acscmd.Dispose()
acsdr.Close()
End Sub

Plase help me with my Project

2
Contributors
1
Reply
15
Views
5 Years
Discussion Span
Last Post by kothaisaravan
0

Hi,

Just select the data from ur database and make it as a datasoure to gridview.
There is no need of DataGridView1(1, 1).Value = (acsdr("Login_Username")).

Use the below format,

Dim ConnString As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=dbname.mdb"
        Dim SQLString As String = "SELECT * FROM tablename"
        Dim OleDBConn1 As System.Data.OleDb.OleDbConnection = New System.Data.OleDb.OleDbConnection(ConnString)
        Dim DataSet1 As New DataSet()
        Dim OleDbDataAdapter1 As System.Data.OleDb.OleDbDataAdapter = New System.Data.OleDb.OleDbDataAdapter(SQLString, OleDBConn1)
        OleDBConn1.Open()
        OleDbDataAdapter1.Fill(DataSet1, "tablename")
        DataGridView1.DataSource = DataSet1.Tables("tablename")
        OleDBConn1.Close()
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.