i'm very much new to vb.
can any body solve my smaaaall problem...?
my problem is; i have a form, in that, two textboxes and a button are there. that is connected (i dont know how to connect, excuse me) with a table in ms access 2007. when i enter some input (for example, student id number) there, and button is pressed, then that data is to be compared with the table's fields and the corresponding value is to be loaded into a variable and that data is to be displayed in textbox 2. (for ex, student id is matched with the table, corresponding student's marks are found from the table and that marks are loaded into the variable and some grace marks are added there and the grand total is displayed)
i'm struggling a lot for this... please help me...

4 Years
Discussion Span
Last Post by AndreRet

What have you attempted so far to solve the problem? Do you know SQL? What sql statement(s) are you using?

If you don't know SQL then you need to study a tutorial.

Also, post the code you have written for this question.


if you are familiar with connecting to access 2003 then just use the following connection string for access 2007

connector.Open "Provider='Microsoft.ACE.OLEDB.12.0';Data Source=Example.accdb"

hope this may help you


i'm using the following code

Dim cn As OdbcConnection
        cn = New OdbcConnection("dsn=MyDSN")
        Dim mystring As String = "Select salary from employeetable where name='" & TextBox1.Text & "'"
        Dim cmd As OdbcCommand = New OdbcCommand(mystring)
        Dim dr As OdbcDataReader
        dr = cmd.ExecuteReader()
        If (dr.Read()) Then
            TextBox2.Text = dr.GetDouble(0)
        End If





i'm getting the problem in the line

dr= cmd.ExecuteReader()

"connection property has not been initialized" ....... this is the warning i'm getting

Edited by baabjitvk


You have created a connection. You have created a command. You have not provided any link between them.

Dim cmd As OdbcCommand = New OdbcCommand(mystring, cn)

You forgot about the cn part. :)

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.