如何将此代码更改为 VB.NET?所以我想用 aDataSet
代替 theADODB.Recordset
和 anOleDb.OleDbConnection
代替ADODB.Connection
.
Set oRs = New ADODB.Recordset
oRs.Open ("Select * from Login Where Username= '" & txtUsername.Text & "'"),oCn, adOpenStatic, adLockOptimistic, _
adCmdText
If txtPassword.Text <> oRs.Fields("Password") Then
Call MsgBox("Incorrect Password", vbOKOnly, "Login Error")
txtPassword.Text = ""
txtPassword.SetFocus
Exit Sub
Else
strUserName = txtUsername.Text 'May need in the future project
strName = oRs.Fields("FirstName") & " " & oRs.Fields("LastName")
frmInstruction.Show
这是我到目前为止所尝试的:
Dim cmd As OleDbCommand = New OleDbCommand("SELECT * FROM Login WHERE Username= '" & txtUsername.Text & "' AND password = '" & txtPassword.Text & "' ", oCn)
Dim sdr As OleDbDataReader = cmd.ExecuteReader()
If (sdr.Read() = True) Then
strUserName = txtUsername.Text
frmInstruction.Show()
'but am having issue with this line of code:
strName = oRs.Fields("FirstName") & " " & oRs.Fields("LastName")