0
我已經有數據庫中的用戶的用戶名和密碼,我想創建一個登錄從兩個文本框連接到數據庫,這是我到目前爲止但它不會工作Visual Basic數據庫登錄 - 代碼將不起作用
Partial Class Pages_Login
Inherits System.Web.UI.Page
Protected Sub btnlogin_Click(sender As Object, e As EventArgs) Handles btnlogin.Click
Dim patientNo As String
Dim password As String
Dim bAuthethicated As Boolean
patientNo = txtuser.Text
password = txtpassword.Text
bAuthethicated = CheckUser(patientNo, password)
If bAuthethicated Then
lblresult.Text() = "Student Number and Password are correct"
Else
lblresult.Text() = "Incorrect Student Number and/or Password"
End If
End Sub
Dim cmdstring As String = "SELECT COUNT(*) FROM Patient Where [email protected] AND Password [email protected]"
conn As New SqlConnection("Data Source=.\SQLEXPRESS;
AttachDbFilename=|DataDirectory|\surgery.mdf;IntegratedSecurity=True; UserInstance=True")
cmd= New SqlCommand(cmdstring, conn)
cmd.Parameters.Add("@PATIENTNO", SqlDbType.nchar).Value = patientNo
cmd.Parameters.Add("@PASSWORD", SqlDbType.nchar).Value = password
conn.Open()
found = CInt(cmd.ExecuteScalar)
End Using
Return (found > 0)
End Function
數生成錯誤已經出現
可以canyone請幫助
親切的問候