Click here to Skip to main content
15,890,512 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
VB
Dim conn As New OleDbConnection
        Dim sConnString As String
        Dim cmd As New OleDbCommand
        Dim da As New OleDbDataAdapter
        Dim dt As New DataTable

        Try
            If Microsoft.VisualBasic.Right(Application.StartupPath, 1) = "\" Then
                sConnString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & Application.StartupPath & "trial.mdb;Persist Security Info=False;"
            Else
                sConnString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & Application.StartupPath & "\trial.mdb;Persist Security Info=False;"
            End If
            conn = New OleDbConnection(sConnString)
            conn.Open()
            cmd.Connection = conn
            cmd.CommandType = CommandType.Text
            cmd.CommandText = "select id,firstname ,lastname,address,mobile from Client"
            da.SelectCommand = cmd
            da.Fill(dt)
            Me.DataGridView1.DataSource = dt
        Catch ex As Exception
            MsgBox(ErrorToString)
        Finally
            conn.Close()
        End Try
    End Sub


please help me
Thanks in advance.
Posted
Updated 14-Sep-13 18:42pm
v2
Comments
Mahesh Bailwal 14-Sep-13 1:50am    
At which line are you getting this error?
TrushnaK 14-Sep-13 2:22am    
can you show your gridview code?

Check the columns in your datagridview, my opinion is there should be more added columns in it.

You just need id, firstname, lastname, address, mobile.
 
Share this answer
 
i have missed the column name in the query.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900