hi

i'm making a little application in vb.net and i need to use a data base. so i used some of my aspx functions and the same data base. the problem is that every time i run the application and do something that needs to get values from that db it gives this error: "error in FROM..."

i'm using this code:

Dim DBliga As OleDbConnection
        Dim DBcomando As OleDbCommand
        Dim DBdatareader As OleDbDataReader
        Dim result

        DBliga = New       OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;
Data Source=I:\Visual Studio 2005\Projects\gestao financeira\gestao financeira\gefi.accdb;Persist Security Info=False;")

        DBliga.Open()

        DBcomando = New OleDbCommand("select nome from user", DBliga)

        DBdatareader = DBcomando.ExecuteReader()
        If DBdatareader.Read Then
            result = DBdatareader.Item(0)
            DBliga.Close()
            DBdatareader.Close()
            seleccionar = result
        End If

the table exists so i don´t know whats the problem...i'm guessing that i can't use access 2007..... does anyone knows whats the problem?

i found the anwser and it's really stupid...

this is my original sql string: "select nome from user" this is the working string: "select nome from [user]" no comments...

hi

i'm making a little application in vb.net and i need to use a data base. so i used some of my aspx functions and the same data base. the problem is that every time i run the application and do something that needs to get values from that db it gives this error: "error in FROM..."

i'm using this code:

Dim DBliga As OleDbConnection
        Dim DBcomando As OleDbCommand
        Dim DBdatareader As OleDbDataReader
        Dim result

        DBliga = New       OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;
Data Source=I:\Visual Studio 2005\Projects\gestao financeira\gestao financeira\gefi.accdb;Persist Security Info=False;")

        DBliga.Open()

        DBcomando = New OleDbCommand("select nome from user", DBliga)

        DBdatareader = DBcomando.ExecuteReader()
        If DBdatareader.Read Then
            result = DBdatareader.Item(0)
            DBliga.Close()
            DBdatareader.Close()
            seleccionar = result
        End If

the table exists so i don´t know whats the problem...i'm guessing that i can't use access 2007..... does anyone knows whats the problem?

you can try this my code below

Imports System.Data.OleDb

Module Module1
Public Function connect() As OleDbConnection
'connection to database access 2007 using password
Dim con As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=..\databasename.accdb;Persist Security Info=True;Jet OLEDB:Database Password=123;"
Dim conec As New OleDbConnection(con)
conec.Open()
Return conec
End Function
End Module

note: this syntac put in formload on your project
---------------
Dim Adapter As New OleDbDataAdapter("select * from tablename order by name asc", Module1.connect)
Dim dt As New DataTable("tablename")
Adapter.Fill(dt)
DataGridView1.DataSource = dt
---------------
your database must put in bin folder in your application
with this code you can access anywhere for your database
n this database using password, if your database not using password
change Persist Security Info=false and without password.

for more goto to http://vbcode.my-php.net

deodid dude you are a life saver.......your suggestion for [user],really helped i have been going through the problem for two days........and finally i have also found the stupid answer for it....
thanks a lot brother.....

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.