Imports System.Data
Imports System.Data.OleDb
Public Class Form1

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim conn As String = "Provider=Microsoft.Jet.OLEDB.12.0;Data Source=G:\Visual Studio Projects\test\dbtest.accdb;Persist Security Info=False"
        Dim cmd As String = "SELECT * FROM Table1"
        Dim adapter As New OleDbDataAdapter(cmd, conn)
        Dim topics As New DataSet("Table1")
        adapter.Fill(topics)
        dg.DataSource = topics

    End Sub

End Class

When debugging cant see anything except a blank data grid viewer .... what am i doing wrong ?????????? I am using Visual Studio 2008 and MS Office 2007 in Vista 64 environment

Try this:

Imports System.Data
Imports System.Data.OleDb
Public Class Form1

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
              Dim connStr As String = "Provider=Microsoft.Ace.OLEDB.12.0;Data Source=G:\Visual Studio Projects\test\dbtest.accdb;Persist Security Info=False"
        Dim con As Ne Oledb.Connection(connStr)
        con.Open()
        Dim cmd As String = "SELECT * FROM Table1"
        Dim adapter As New OleDbDataAdapter(cmd, con)
        Dim topics As New DataTable
        adapter.Fill(topics)
        dg.DataSource = topics
     con.Close()
    End Sub

End Class

THANKS !!! it worked like a charm .... it seems that instead of Dataset i had to use Data Table ....

Now a new problem ... i'm a noob in VS 08 .... :(
I'm trying to add text from two text boxes to two fields in the database ... username and password ..... this is the code :

Private Sub Add_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Add.Click

        Dim objcommand1 As New OleDb.OleDbCommand("INSERT INTO Customers (username) VALUES (@username)", con)
        Dim objcommand2 As New OleDb.OleDbCommand("INSERT INTO Customers (password) VALUES (@password)", con)
        objcommand1.Parameters.AddWithValue("@username", user.Text)
        objcommand2.Parameters.AddWithValue("@password", pass.Text)
        con.Open()
        objcommand1.ExecuteNonQuery()
        objcommand2.ExecuteNonQuery()
        con.Close()
    End Sub
End Class

Now , the string in the "user.text" adds under the "username" field like a charm , but the string in "pass.text" refuses to be added .
The error generated is : "Syntax error in the INSERT command" and the "objcommand2.ExecuteNonQuery()" line is highlighted .....

what changes should be done ???

Hey pal, remember that "PASSWORD" is a reserved word for some databases so why not change it to "MyPassword".

In other aspect, you created two separate statements in the same table. why not come up with:

Dim objcommand1 As New OleDb.OleDbCommand("INSERT INTO Customers (username,MyPassword) VALUES (@username, @password)", con)
This article has been dead for over six months. Start a new discussion instead.