<%@ Page Language="VB" ContentType="text/html" ResponseEncoding="gb2312" Debug=true %><%@ Import NameSpace="System.Data" %> <%@ Import NameSpace="System.Data.OleDb" %><html> <head> <script Language="VB" RunAt="Server">Dim objConn As OleDbConnection Dim strSQL As String '检查是否有重复帐号 Function Check_ID(account As String) As Boolean Dim objDR As OleDbDataReader Dim objCmd As OleDbCommand
strSQL = "select * from UserDates where useraccount= '" & account & "' "
objCmd = New OleDbCommand (strSQL, objConn)
objCmd.Connection.Open()
objDR = objCmd.ExecuteReader()
Check_ID = False While objDR.Read() Check_ID = True End WhileobjCmd.Connection.Close() End Function '添加信息到数据库 Sub Insert_Dates(Sender As Object, E As EventArgs) Dim objCmd As OleDbCommand Dim strSQL, strDSN As StringDim UserAccount, PassWord, UserName, EMail, Address As String
记得以前用这种方式更新数据库的时候由于被更新的数据表没有主键会出现这样的错误提示的。----------------------------------------------------------------
欢迎试用ASP.NET大文件上传组件
http://bestcomy.europe.webmatrixhosting.net
----------------------------------------------------------------
须要经数据所在的目录添加一个Evrryone用户,并给它写的写的权限就行了,
祝好运~!
<%@ Import NameSpace="System.Data.OleDb" %><html>
<head>
<script Language="VB" RunAt="Server">Dim objConn As OleDbConnection
Dim strSQL As String
'检查是否有重复帐号
Function Check_ID(account As String) As Boolean Dim objDR As OleDbDataReader
Dim objCmd As OleDbCommand
strSQL = "select * from UserDates where useraccount= '" & account & "' "
objCmd = New OleDbCommand (strSQL, objConn)
objCmd.Connection.Open()
objDR = objCmd.ExecuteReader()
Check_ID = False
While objDR.Read()
Check_ID = True
End WhileobjCmd.Connection.Close()
End Function
'添加信息到数据库
Sub Insert_Dates(Sender As Object, E As EventArgs)
Dim objCmd As OleDbCommand
Dim strSQL, strDSN As StringDim UserAccount, PassWord, UserName, EMail, Address As String
UserAccount = Request.Form("text1")
PassWord = Request.Form("text2")
UserName = Request.Form("text3")
Email = Request.Form("text4")
Address = Request.Form("text5") strDSN = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("/BOOKSHOP/bsdb.mdb") objConn = New OleDbConnection(strDSN)
If Not Check_ID(UserAccount) Then
strSQL = "Insert Into UserDates values('" & UserAccount &"', '" & _
PassWord &"', '" & UserName & "', '" & EMail & "', '" & Address &"')"
objConn = New OleDbConnection(strDSN)
objCmd = New OleDbCommand (strSQL, objConn)
objCmd.Connection.Open()
objCmd.ExecuteNonQuery()
objCmd.Connection.Close()
Response.Write("Success")
Else
Response.Write("Fail")
Response.Write("<hr><a href ='javascript:history.go(-1)'>")
Response.Write("上一页</a>")
End If
End Sub </script>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>注册页面</title>
</head>
<body>
<h2 class="style1">欢迎注册</h2><table width="765" border="0">
<tr>
<td height="350">
<form method="post" name="insert" runat="server">
<ul>
帐号:<li> <asp:TextBox ID="text1" runat="server" MaxLength="20" /> <br>
密码:<li> <asp:TextBox ID="text2" runat="server" TextMode="Password" /><br>
姓名:<li> <asp:TextBox ID="text3" runat="server" /> <br>
E-Mail:<li><asp:TextBox ID="text4" runat="server" MaxLength="40" /><br>
地址<br><asp:TextBox ID="text5" runat="server" MaxLength="40" /> <br>
</ul>
<p>
<asp:Button ID="Button" Text="注册" OnClick="Insert_Dates" runat="server" />
</p>
</form> </td>
</tr>
</table>
</body>
</html>
如果是XP或windows2003,工具->文件夹选项->取消简单文件共享
MDB文件->右键->添加everyone完全权限
上面那位 wggwan(明天会更好) 大哥,源码贴出来了.....不知怎样添加asp.net帐户?
此问题急待解决,请大家帮帮忙!