Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
If TextBox1.Text = "" Or TextBox2.Text = "" Then Label3.Text = "请确认您的输入!" Return End If Dim conn As SqlConnection Dim Config As Hashtable Config = Context.GetConfig("appsettings") conn = New SqlConnection(Config("conn")) Dim sql As String = "select * from TABLE1 where id=@id and pwd=@pwd" Dim comm As SqlCommand = New SqlCommand(sql, conn) comm.Parameters.Add(New SqlParameter("@id", SqlDbType.Char, 20)) comm.Parameters("@id").Value = TextBox1.Text comm.Parameters.Add(New SqlParameter("@pwd", SqlDbType.Char, 20)) comm.Parameters("@pwd").Value = TextBox2.Text Dim dr As SqlDataReader conn.Open() dr = comm.ExecuteReader If dr.Read Then Session("id") = TextBox1.Text dr.Close() comm.Cancel() Dim sql_3 As String = "update stu_base set point=point+1 where id=@id" comm = New SqlCommand(sql_3, conn) comm.Parameters.Add(New SqlParameter("@id", SqlDbType.Char, 20)) comm.Parameters("@id").Value = Session("id") comm.ExecuteNonQuery() comm.Cancel() Response.Redirect("WebForm2.aspx") Else Label3.Text = "您还没有注册或账号密码错误" End If End Sub
这是一个登录验证界面,WebForm2.aspx是要打开的新窗口, 请问这里的Sql Connection怎么连接不上数据库呢?该怎么用呢?谢谢!