VB.net代码,连接access数据库 帐户是管理员,密码为:hope-action@126.com
朋友们,昨办呢?
///
<!--#include file="AdoConn.inc"-->
<%@ Page Language="VB" ContentType="text/html" ResponseEncoding="gb2312" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script language ="VB" runat="server">
Dim flag As Integer = 1
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs)
If flag >= 3 Then
Response.Redirect("reg.aspx")
Exit Sub
Else
Dim man As String
man = myuser.Text '输入的登录名
Dim code As String = mypass.Text
Dim ds As New DataSet
Dim tempstr As String = "select password from member where name='" & man & "'"
ds = createDataset(tempstr, "47xz.mdb", "member")
Dim member As DataTable = ds.Tables("member")
Try
If member.Rows(0).Item(0) <> code Then
showresult.Text = "用户名或密码错误,请重新输入!"
Else
membertext.Text = "欢迎您:" & man
Session("user") = man
hidecontrol()
End If
Catch ex As Exception
showresult.Text = "用户名或密码错误,请重新输入!"
End Try
End If
flag = flag + 1
End Sub
//其中AdoConn.inc文件内容如下:
<%@ Import Namespace ="system.data" %>
<%@ Import Namespace ="system.data.oledb" %>
<script language ="VB" runat="server">
Function createDataset(ByVal strSQL As String, ByVal filename As String, ByVal tablename As String) As DataSet
Dim conn As New OleDbConnection
Dim cmd As New OleDbCommand
conn.ConnectionString = "Provider=Microsoft.jet.OLEdb.4.0;password=hope-action@126.com;user id=admin;Data source=" & Server.MapPath("47xz.mdb")
conn.Open()
cmd.Connection = conn
cmd.CommandText = strSQL
Dim objadpt As New OleDbDataAdapter(cmd)
Dim ds As New DataSet
objadpt.Fill(ds, tablename)
createDataset = ds
conn.Close()
End Function
</script>
//以下为出错信息:
Server Error in '/' Application.
--------------------------------------------------------------------------------
无法启动应用程序。工作组信息文件丢失,或是已被其它用户以独占方式打开。
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Data.OleDb.OleDbException: 无法启动应用程序。工作组信息文件丢失,或是已被其它用户以独占方式打开。
Source Error:
Line 7: Dim cmd As New OleDbCommand
Line 8: conn.ConnectionString = "Provider=Microsoft.jet.OLEdb.4.0;password=hope-action@126.com;user id=admin;Data source=" & Server.MapPath("47xz.mdb")
Line 9: conn.Open()
Line 10: cmd.Connection = conn
Line 11: cmd.CommandText = strSQL
Source File: E:\my\webpage\AdoConn.inc Line: 9
[此贴子已经被作者于2007-7-20 23:35:46编辑过]