登陆的问题,把我弄晕了,我做不出来了
数据库是两个表,一个USERGROUP(UID char,PWD char,BID int)另一个是车间表bottler(Bid int,bname char)
登陆界面有两个文本框,一个dropdownlist(从BOTTLER里取植)
问题是我在文本框里如果输入字符,可以,如果输入数字,就错了,我调试了一早上,现在是有时可以,有时就不可以,为什么呢?
CODE:
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'在此处放置初始化页的用户代码
Dim ConStr As String = ConfigurationSettings.AppSettings("OTS")
Dim Cnn As New SqlConnection(ConStr)
Dim SqlStr As String = "select * from bottler"
Dim ObjCmd As New SqlCommand(SqlStr, Cnn)
If Not IsPostBack Then
Cnn.Open()
Dim ObjRead As SqlDataReader = ObjCmd.ExecuteReader
DDLBot.DataSource = ObjRead
DDLBot.DataValueField = "id"
DDLBot.DataTextField = "bottler"
DDLBot.DataBind()
End If
Cnn.Close()
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim ConStr As String = ConfigurationSettings.AppSettings("OTS")
Dim Cnn As New SqlConnection(ConStr)
Dim SqlStr As String = "select * from usergroup where uid = '" + TxtUid.Text.Trim().ToString + "'and pwd='" + TxtPwd.Text.Trim().ToString + "' and bid='" & DDLBot.SelectedItem.Value & "'"
Try
Dim cmd As New SqlCommand(SqlStr, Cnn)
Cnn.Open()
Dim StrCount As String
StrCount = cmd.ExecuteScalar
If StrCount = "1" Then
Response.Redirect("OtsMain.aspx")
Else
Response.Redirect("loginerr.aspx")
End If
Catch er As Exception
Response.Write(er.Message())
End Try
Cnn.Close()
End Sub