我想改变这个参数化查询
On Error Resume Next
Dim timex As String
Dim isigroup As DataTable
objdata = New clsMSSQL
isigroup = objdata.QueryDatabase("SELECT * FROM Userx WHERE Username='" & txtuser.Text & "' AND Userpass ='" & txtpassword.Text & "'")
If isigroup.Rows.Count > 0 Then
For i = 0 To isigroup.Rows.Count - 1
If isigroup.Rows(i)("username") <> txtuser.Text Or isigroup.Rows(i)("userpass") <> txtpassword.Text Then
MsgBox("Access denied username and password !!!", MsgBoxStyle.Information, "Attention.....")
xcountx = xcountx + 1
If xcountx >= 3 Then
MsgBox("You have reach the maximum time of login !!", MsgBoxStyle.Exclamation, "Προσοχή.....")
End
End If
Exit Sub
End If
Next
username = isigroup.Rows(0)("Username")
xUser_ID = isigroup.Rows(0)("User_id")
xUser_Access = isigroup.Rows(0)("Access_Type")
timex = TimeOfDay
isigroup = objdata.QueryDatabase("INSERT INTO Audit_Log (User_ID, Login) VALUES(" & xUser_ID & ", '" & timex & "')")
isigroup = objdata.QueryDatabase("SELECT * FROM Audit_Log ORDER BY LOG_ID DESC")
LOGID = isigroup.Rows(0)("LOG_ID")
Audit_Trail(xUser_ID, TimeOfDay, "Login to system ")
我尝试了很多,但我无法做到,请帮忙
这是课
Imports System.Data.SqlClient
Public Class clsMSSQL
Public Shared con As New SqlConnection(constring)
Private DbSwtable As DataTable
Public Function QueryDatabase(ByVal Query As String) As DataTable
Try
Dim objDataSet As New DataSet
Dim objDataTable As New DataTable
Dim objDataAdapter As New SqlDataAdapter(Query, con)
objDataAdapter.Fill(objDataSet, "DefaultTable")
objDataTable = objDataSet.Tables("DefaultTable")
con.Close()
Return objDataTable
Catch ex As Exception
MessageBox.Show(ex.Message, "Λάθος", MessageBoxButtons.OK, MessageBoxIcon.Error)
Return DbSwtable
End Try
End Function