hi
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...

Recommended Answers

All 8 Replies

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

        dr.Close()

        cmd.Dispose()

        cn.Open()

        cn.Close()

i'm getting the problem in the line

dr= cmd.ExecuteReader()

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

What does the error say?

Sorry, ignore. just saw the error...

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. :)

thank you very much...
its working..
thank you AndreRet

:) Only a pleasure. Please mark as solved, thanx.

Happy coding...

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.