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

lets see your code.

and what exactly is the error message ?

This is a VB.Net question, I have asked the mods to move it from here (vb4/5/6) to .Net.

commented: Done. Thanks for reporting. +16
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.

change your code in line 11 with this following code :

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

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

hi can some one help me and send me the right code for save button by using ms access2007 with vb.net 2008 my email is faari22@hotmail.com

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.