ADO .NET equivalent of DAO codes

A

Alice

I have the following codes in VB which I need to convert to VB .NET 03.
It is the code for a command button click event in a form named frmLogin.

I have created a OleDbConnection Control, a OleDbDataAdapter Control and a
DataSet Control in my frmLogin(.net 03 version) to access another table
visually.
Do I need to create a new data connnection, data adapter, command object and
data set in codes in order to do what is done below or can I re-use the
controls somehow?

Can anybody help to convert the following codes to VB .Net 03? Thanks.

Private Sub cmdLogin_Click()
Dim UserMasterTb As Recordset

Set UserMasterTb = SYS_DB.OpenRecordset("User_Master", dbOpenTable)
With UserMasterTb
.Index = "PrimaryKey"
.Seek "=", Trim$(UCase(txtUserID.Text))
If Not .NoMatch Then 'userid found in database.
If Trim$(txtPassWd.Text) = Decrypt(![Usr_PassWd]) Then 'Password
correct.
CurrUserID_ = ![Usr_ID]
CurrUserLevel_ = ![Usr_Lvl]
End If
End If
End With

UserMasterTb.Close
Set UserMasterTb = Nothing
End Sub
 
C

Cor

Hi Alice,

I was trying to make some changes but it would be rewriting the total part.
You are saying you are using a OleDBconnection Control, etc. I asume you
did use the wizards for it.

But you are using a recordset so that you have to skip.
Therefore I cannot see everything and make some little changes but it is not
all.
Private Sub cmdLogin_Click()
Dim UserMasterTb As Recordset
I think that you needs here something as
Oledbdatadapter1.fill(dataset11)


Then you can access the dataset and if it has a primary key you can use the
find instruction which is a member of "datarowcollections.find" if there is
not a key you can use the "datatable.select" or a for each loop through the
dataset.

It is a little bit confusing that all those methods are in different
classes, but now you know where.

And I think it is better not set things to nothing anymore.

close them if possible.

I hope this helps?

Cor
 

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