DataSets in Console Applications

K

KellyLeia

I'm trying to rewrite a console application from VB6 to .Net 2005 that
moves users and computer about in active directory. To start, its
grabs current users from our AS400 box and throws them into a table in
SQL. It then queries SQL and Active Directory, compares, and
adds/updates/removes users. What i'm trying to do here is just open up
a dataset and connect to the AD table. When i run this, it throws the
error "91, ADSynch, Object reference not set to an instance of an
object." I threw this code into a datagrid, adding the datasource and
databind methods, and it works fine, showing everything. Is there
something special I need to do to make datasets work in consoles?

Dim strSQL As String = "SELECT * FROM ADV_setAD"
Dim objConnection As SqlConnection = New SqlConnection(strConnString)
Dim dsDataSet As New DataSet
Dim daDataAdapter As SqlDataAdapter = New SqlDataAdapter(strSQL,
objConnection)
Dim r As DataRow
Dim dt As New DataTable("AD")
daDataAdapter.Fill(dsDataSet, "AD")
objConnection.Dispose()
daDataAdapter.Dispose()


'Check if CN is null, then the user is new a needs to be
created.
For Each r In dsDataSet.Tables("AD").Rows
'store current ads path
strAdspath = r("stored_adspath")
''''more code here that doesn't really execute because
there's no records to act upon.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top