源程序:<%@ Page Language="VB" %>
<%@ import Namespace="system.data" %>
<%@ import Namespace="system.data.oledb" %>
<%@ import Namespace="system.web.security" %>
<script runat="server"> sub page_load()
dim strcnndepart as string="provider=microsoft.jet.oledb.4.0;" & _
"data source=d:\meeting\m3r.mdb"
dim cnndepart as new oledbconnection(strcnndepart)
dim strsqldepart as string="SELECT tblDepartment.DepartID, tblDepartment.Department_Cn " & _
"FROM tblDepartment"
dim cmddepart as new oledbcommand(strsqldepart,cnndepart)
cnndepart.open()
drpdldepartment.datasource=cmddepart.executereader(commandbehavior.closeconnection)
drpdldepartment.databind()
'test.datasource=cmdlogin.executereader(commandbehavior.closeconnection)
'test.databind()
account.text=user.identity.name
'add user's detail to the table
end sub
Sub LoginBtn_Click(Sender As Object, E As EventArgs)
dim strcnn as string
dim strsql as string
dim objdataset as new dataset()
dim objcnn as oledbconnection
dim objadapter as oledbdataadapter
' set the connection and query details
strcnn="provider=microsoft.jet.oledb.4.0;" & _
"data source=d:\meeting\m3r.mdb"
strsql="SELECT tblaccount.Accountid, tblaccount.Accountname FROM tblaccount "& _
"WHERE (((tblaccount.Accountname)='" & user.identity.name & "'))"
'open the connection and set the command
objcnn=new oledbconnection(strcnn)
objadapter=new oledbdataadapter(strsql,objcnn)
'fill the dataset with the data
objadapter.fill(objdataset,"tblaccount")
'add new row to the table
dim objtable as datatable
dim objnewrow as datarow
objtable=objdataset.tables("tblaccount")
objnewrow=objtable.newrow()
objnewrow("accountname")=user.identity.name
objtable.rows.add(objnewrow)
'generate the update commands
dim objbuilder as oledbcommandbuilder
objbuilder=new oledbcommandbuilder(objadapter)
objadapter.updatecommand=objbuilder.getupdatecommand()
objadapter.insertcommand=objbuilder.getinsertcommand()
objadapter.deletecommand=objbuilder.getdeletecommand()
'update the data store
objadapter.update(objdataset,"tblaccount")
'get the accounid
<%@ import Namespace="system.data" %>
<%@ import Namespace="system.data.oledb" %>
<%@ import Namespace="system.web.security" %>
<script runat="server"> sub page_load()
dim strcnndepart as string="provider=microsoft.jet.oledb.4.0;" & _
"data source=d:\meeting\m3r.mdb"
dim cnndepart as new oledbconnection(strcnndepart)
dim strsqldepart as string="SELECT tblDepartment.DepartID, tblDepartment.Department_Cn " & _
"FROM tblDepartment"
dim cmddepart as new oledbcommand(strsqldepart,cnndepart)
cnndepart.open()
drpdldepartment.datasource=cmddepart.executereader(commandbehavior.closeconnection)
drpdldepartment.databind()
'test.datasource=cmdlogin.executereader(commandbehavior.closeconnection)
'test.databind()
account.text=user.identity.name
'add user's detail to the table
end sub
Sub LoginBtn_Click(Sender As Object, E As EventArgs)
dim strcnn as string
dim strsql as string
dim objdataset as new dataset()
dim objcnn as oledbconnection
dim objadapter as oledbdataadapter
' set the connection and query details
strcnn="provider=microsoft.jet.oledb.4.0;" & _
"data source=d:\meeting\m3r.mdb"
strsql="SELECT tblaccount.Accountid, tblaccount.Accountname FROM tblaccount "& _
"WHERE (((tblaccount.Accountname)='" & user.identity.name & "'))"
'open the connection and set the command
objcnn=new oledbconnection(strcnn)
objadapter=new oledbdataadapter(strsql,objcnn)
'fill the dataset with the data
objadapter.fill(objdataset,"tblaccount")
'add new row to the table
dim objtable as datatable
dim objnewrow as datarow
objtable=objdataset.tables("tblaccount")
objnewrow=objtable.newrow()
objnewrow("accountname")=user.identity.name
objtable.rows.add(objnewrow)
'generate the update commands
dim objbuilder as oledbcommandbuilder
objbuilder=new oledbcommandbuilder(objadapter)
objadapter.updatecommand=objbuilder.getupdatecommand()
objadapter.insertcommand=objbuilder.getinsertcommand()
objadapter.deletecommand=objbuilder.getdeletecommand()
'update the data store
objadapter.update(objdataset,"tblaccount")
'get the accounid
解决方案 »
- 一個关于linq查詢語句的写法
- 将字符串转换为 uniqueidentifier 时失败。
- 如何在页面中获取microphone数据
- 无效的 SQL语句;期待 'DELETE'、'INSERT'、'PROCEDURE'、'SELECT'、或 'UPDATE'。各位大哥看看?急!
- 小弟的RSS在FOXMAIL中做测试时显示没有自动获得到newsfeed的信息,求教(孟子E章大哥)!!!!代码如下
- asp.net面向对象性能的探讨
- asp.net 疑问??? 高手请进 帮帮忙
- js版中没有解决的问题
- CSDN的信誉总分是怎样算出来的呀?
- 大家有没有c#对应这个java.des的代码
- (转载)这才是真正的...Hero 行为
- 哪里有好的asp.net的论坛
"WHERE (((tblaccount.Accountname)='" & account.text & "'))"
objcnn.open
dim objcmd as new oledbcommand(strsql,objcnn)
dim objdatareader as oledbdatareader
dim accountIDnmb as string
objdatareader=objcmd.executereader()
accountidnmb=objdatareader("accountid")
objdatareader.close
'objdatareader=nothing
'get the departid
dim departidnmb as string
strsql="SELECT tblDepartment.DepartID, tblDepartment.Department_Cn " & _
"FROM tblDepartment WHERE (((tblDepartment.Department_Cn)='" & request.form("drpdldepartment") & "'))"
objcmd=new oledbcommand(strsql,objcnn)
objdatareader=objcmd.executereader()
departidnmb=objdatareader("departid")
objdatareader.close
'objdatareader=nothing
objcnn.close
' insert the new data into the tblemployee
'open the connection and set the command
strsql="SELECT tblEmployee.AccountID, tblEmployee.DepartID, tblEmployee.FirstName_Cn, tblEmployee.LastName_Cn, tblEmployee.Extension, tblEmployee.Email " & _
"FROM tblEmployee WHERE (((tblEmployee.FirstName_Cn)='" & firstname.text & "') AND ((tblEmployee.LastName_Cn)='" &lastname.text &"'))"
objadapter=new oledbdataadapter(strsql,objcnn)
'fill the dataset
objadapter.fill(objdataset,"tblemployee")
objtable=objdataset.tables("tblemployee")
objnewrow=objtable.newrow()
objnewrow("firstname_cn")=firstname.text
objnewrow("lastname_cn")=lastname.text
'objnewrow("departid")=departidnmb
'objnewrow("accountid")=accountidnmb
objnewrow("email")=email.text
objnewrow("extension")=extension.text
objtable.rows.add(objnewrow)
'update the data
objbuilder=new oledbcommandbuilder(objadapter)
objadapter.updatecommand=objbuilder.getupdatecommand()
objadapter.insertcommand=objbuilder.getinsertcommand()
objadapter.deletecommand=objbuilder.getdeletecommand()
objadapter.update(objdataset,"tblemployee")
'Msg.Text = "Invalid Credentials: Please try again"
End Sub
'Sub Dropdownlist1_SelectedIndexChanged(sender As Object, e As EventArgs)
'End Sub
Sub DropDownList1_SelectedIndexChanged(sender As Object, e As EventArgs)
End Sub</script>
<html>
<head>
</head>
<body style="FONT-FAMILY: arial">
<form runat="server">
<h2>为了便于管理,请登记个人信息
</h2>
<hr size="1" />
<table>
<tbody>
<tr>
<td>
名 字:</td>
<td>
<asp:TextBox id="firstName" runat="server"></asp:TextBox>
</td>
<td>
<asp:RequiredFieldValidator id="Requiredfieldvalidator1" runat="server" ErrorMessage="*" Display="Static" ControlToValidate="firstName"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td>
姓 氏:</td>
<td>
<asp:TextBox id="lastname" runat="server"></asp:TextBox>
</td>
<td>
<asp:RequiredFieldValidator id="Requiredfieldvalidator2" runat="server" ErrorMessage="*" Display="Static" ControlToValidate="lastname"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td>
部 门:</td>
<td>
<asp:DropDownList id="Drpdldepartment" runat="server" OnSelectedIndexChanged="Dropdownlist1_SelectedIndexChanged" datavalue="Departid" datatextfield="Department_cn" Width="160px"></asp:DropDownList>
</td>
</tr>
<tr>
<td>
分 机 号:</td>
<td>
<asp:TextBox id="extension" runat="server"></asp:TextBox>
</td>
<td>
<asp:RequiredFieldValidator id="RequiredFieldValidator4" runat="server" ErrorMessage="*" Display="Static" ControlToValidate="extension"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td>
Email:</td>
<td>
<asp:TextBox id="email" runat="server"></asp:TextBox>
</td>
<td>
<asp:RequiredFieldValidator id="RequiredFieldValidator5" runat="server" ErrorMessage="*" Display="Static" ControlToValidate="email"></asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td>
</td>
<td>
<asp:TextBox id="account" runat="server" Visible="False"></asp:TextBox>
</td>
<td>
<asp:RequiredFieldValidator id="RequiredFieldValidator6" runat="server" ErrorMessage="*" Display="Static" ControlToValidate="account"></asp:RequiredFieldValidator>
</td>
</tr>
</tbody>
</table>
<p>
</p>
<p>
</p>
<p>
<asp:button id="LoginBtn" onclick="LoginBtn_Click" runat="server" text="确认"></asp:button>
</p>
<p>
<asp:Label id="Msg" runat="server" ForeColor="red"></asp:Label>
</p>
<p>
</p>
</form>
</body>
</html>