このコードを VB.NET に変更するにはどうすればよいですか? DataSet
だから私は の代わりにADODB.Recordset
と のOleDb.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")