| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 514 人关注过本帖
标题:[求助]连接数据库出错了
只看楼主 加入收藏
鬼正
Rank: 1
等 级:新手上路
帖 子:96
专家分:0
注 册:2006-12-15
收藏
 问题点数:0 回复次数:3 
[求助]连接数据库出错了

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编辑过]

搜索更多相关主题的帖子: 数据库 
2007-07-20 23:29
udbyygy
Rank: 1
等 级:新手上路
威 望:2
帖 子:226
专家分:0
注 册:2007-6-26
收藏
得分:0 
难办

2007-07-21 12:33
bygg
Rank: 16Rank: 16Rank: 16Rank: 16
来 自:乖乖的心中
等 级:版主
威 望:241
帖 子:13555
专家分:3076
注 册:2006-10-23
收藏
得分:0 
把连接代码写到后台去,加个try..catch..就明白了

飘过~~
2007-07-21 16:03
皎月初斜
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2007-7-21
收藏
得分:0 
顶顶,我也是这个问题啊
2007-07-21 17:58
快速回复:[求助]连接数据库出错了
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.025332 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved