主题:我用oledb连接acess出问题
Dim connstring As String
Dim strsql As String
Dim i As Integer
Dim conn As New OleDbConnection
connstring = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="
connstring += Server.MapPath("db1.mdb")
conn.ConnectionString = connstring
conn.Open()
Dim cmd As New OleDbCommand
Dim reader As OleDbDataReader
Try
strsql = "select * from member"
cmd.Connection = conn
cmd.CommandText = strsql
reader = cmd.ExecuteReader
Response.Write("<table border=1>")
Response.Write("<tr><td>用户</td>")
Response.Write("<td>密码</td>")
Response.Write("<td>电话</td>")
Response.Write("<td>地址</td>")
Response.Write("<td>Email</td></tr>")
Do While reader.Read
Response.Write("<tr>")
For i = 0 To 4
Response.Write("<td>" & reader.Item(i) & "</td>")
Next
Response.Write("</tr>")
Loop
Response.Write("</table>")
Catch ex As Exception
Response.Write("不能输出")
End Try
cmd.Dispose()
conn.Close()
其中连接acess中老是出错,
connstring = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="
connstring += Server.MapPath("db1.mdb")
conn.ConnectionString = connstring
conn.Open()
只要是自己写,就出错,能不能解释解释,是不是格式的问题
Dim strsql As String
Dim i As Integer
Dim conn As New OleDbConnection
connstring = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="
connstring += Server.MapPath("db1.mdb")
conn.ConnectionString = connstring
conn.Open()
Dim cmd As New OleDbCommand
Dim reader As OleDbDataReader
Try
strsql = "select * from member"
cmd.Connection = conn
cmd.CommandText = strsql
reader = cmd.ExecuteReader
Response.Write("<table border=1>")
Response.Write("<tr><td>用户</td>")
Response.Write("<td>密码</td>")
Response.Write("<td>电话</td>")
Response.Write("<td>地址</td>")
Response.Write("<td>Email</td></tr>")
Do While reader.Read
Response.Write("<tr>")
For i = 0 To 4
Response.Write("<td>" & reader.Item(i) & "</td>")
Next
Response.Write("</tr>")
Loop
Response.Write("</table>")
Catch ex As Exception
Response.Write("不能输出")
End Try
cmd.Dispose()
conn.Close()
其中连接acess中老是出错,
connstring = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="
connstring += Server.MapPath("db1.mdb")
conn.ConnectionString = connstring
conn.Open()
只要是自己写,就出错,能不能解释解释,是不是格式的问题