VB.NET登录问题
本帖最后由 wuyazhe 于 2013-06-03 15:08:47 编辑
Public Function OracleProductConn(Optional ByVal strConfig As String = "connectionString") As OracleConnection
Dim DBConn As New OracleConnection()
Dim strConn As String = ConfigurationManager.ConnectionStrings(strConfig).ConnectionString
DBConn.ConnectionString = strConn
Return DBConn
End Function
Public Function GetInfoDT(ByVal strSql As String, Optional ByVal strConfig As String = "") As DataTable
Dim DT As New DataTable()
Dim Conn As OracleConnection
If strConfig = "" Then
Conn = OracleProductConn()
Else
Conn = OracleProductConn(strConfig)
End If
If Conn.State <> ConnectionState.Open Then Conn.Open()
Dim dar As New OracleDataAdapter(strSql, Conn)
dar.Fill(DT)
dar.Dispose()
dar = Nothing
If Conn.State = ConnectionState.Open Then Conn.Close()
Conn = Nothing
Return DT
End Function
Protected Sub btnLogin_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnLogin.Click
If txtUser.Text.Trim() = "" Then
MsgBox("user不能为空")
Exit Sub
End If
If txtPass.Text.Trim() = "" Then
MsgBox("Password不能为空")
Exit Sub
End If
Call IsLogin()
End Sub
Private Sub IsLogin()
Dim sql As String = ""
sql += "select * from Users where UserName='" & txtUser.Text.Trim & "' and Password='" & txtPass.Text.Trim & "'"
Dim oDT As New DataTable
oDT = clsSQL.GetInfoDT(sql, "WEBTEST")
If oDT.Rows.Count > 0 Then
'MsgBox("OK")
Response.Redirect("work.aspx")
Else
MsgBox("No")
End If
End Sub
这段代码写的对不对,登录名和密码都正确,直接弹出“No”的对话框