I'm trying to create a program that will connect to my access database and perform a simple query. Then I want to put the data (image and other info) into active directory. But I keep getting this "Declaration expected" error when I'm setting up my connection. Can someone please take a look? I'm a complete noobie to VB!

I'm using Visual Studio Ultimate.

http://img845.imageshack.us/img845/6914/40103193.png

Thank you

Option Explicit On
Public Class Form1
    Private cn As ADODB.Connection
    Private rs As ADODB.Recordset
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        cn = New ADODB.Connection
        cn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
                              "Data Source=C:\Users\Bao\Desktop\Capstone\db1.mdb"
        cn.Open()
        rs = New ADODB.Recordset
        rs.Open("Select * FROM student", cn)
        MsgBox("Total Number of records = " & rs.RecordCount)

        cn.Close()
    End Sub
End Class

I'm not getting the results I want. It keeps display -1 but it should 10 since there are 10 records in the student table.

Edited 5 Years Ago by huBelial: n/a

change your code in line 11 with this following code :

rs.Open("Select * FROM student", cn, ADODB.CursorTypeEnum.adOpenStatic, ADODB.LockTypeEnum.adLockBatchOptimistic, 1)

Edited 5 Years Ago by Jx_Man: n/a

why not use

Select (*) FROM student

that will give the count and is much faster, even better if you count particular indexed column.

Thank you so much guys. I have figured out how to pull data from my Access database.

Now I need to figure out how import the data (which consists of an jpeg images and regular data) into my lightweight active directory. Can you guys tell me where I can look up useful tutorials to accomplish this task?

Great job..
if you have another question then please make a new thread for it.
also please mark this thread as solved.

Now I need to figure out how import the data (which consists of an jpeg images and regular data) into my lightweight active directory. Can you guys tell me where I can look up useful tutorials to accomplish this task?

We were talking about ambushes earlier on in another thread.:) This seems to be one. One solution is given and another question pops up.

Please posters, open a new thread if you have a different question than the original one asked. Also mark your posts as solved if the solution was given. We are all suckers for punishment.;)

This article has been dead for over six months. Start a new discussion instead.