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

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()
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.