用acess链接数据库
Imports System.Data.OleDb
Partial Class Front_Login
Inherits System.Web.UI.Page Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim conn As New OleDbConnection conn.ConnectionString = "provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("../App_Data/db1.mdb")
conn.Open() Dim sql As String
sql = "select * FROM 学生信息表" & "WHERE 学生姓名='" & TextBox1.Text & "'AND 学号='" & TextBox2.Text & "'" Dim comm As New OleDbCommand(sql, conn)
Dim dr As OleDbDataReader = comm.ExecuteReader()(此处提示用户未处理的代码 OleDbException) If dr.Read = True Then
Session("xm") = dr("学生姓名")
Session("bj") = dr("班级名称")
Session("xh") = dr("学号") conn.Close()
Response.Redirect("kclb.aspx")
Else
Response.Write("cao")
End If End Sub Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Session("xm") = ""
Session("bj") = ""
Session("xh") = ""
End Sub
End Class
Imports System.Data.OleDb
Partial Class Front_Login
Inherits System.Web.UI.Page Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim conn As New OleDbConnection conn.ConnectionString = "provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("../App_Data/db1.mdb")
conn.Open() Dim sql As String
sql = "select * FROM 学生信息表" & "WHERE 学生姓名='" & TextBox1.Text & "'AND 学号='" & TextBox2.Text & "'" Dim comm As New OleDbCommand(sql, conn)
Dim dr As OleDbDataReader = comm.ExecuteReader()(此处提示用户未处理的代码 OleDbException) If dr.Read = True Then
Session("xm") = dr("学生姓名")
Session("bj") = dr("班级名称")
Session("xh") = dr("学号") conn.Close()
Response.Redirect("kclb.aspx")
Else
Response.Write("cao")
End If End Sub Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Session("xm") = ""
Session("bj") = ""
Session("xh") = ""
End Sub
End Class
=>
conn.ConnectionString = "provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("~/../App_Data/db1.mdb")