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)

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

acscmd.Connection = conn
Dim acsdr As OleDbDataReader = acscmd.ExecuteReader

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

End Sub

Plase help me with my Project


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)
        OleDbDataAdapter1.Fill(DataSet1, "tablename")
        DataGridView1.DataSource = DataSet1.Tables("tablename")
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.