当前位置: 首页 > 图文教程 > 网络编程 > ASP.NET > AddNew Method Example

ASP.NET
如何在命令行下编译一个asp.net项目
ADO 与ADO.NET
当VS.NET2003遇上VS.NET2005,WebService部署何去何从
昨日关注:逐步解说: 将Web Form网页国际化
在.NET下编写中文代码程序
防止同一个程序多次运行。 [VB.NET]
Visual C#设计多功能关机程序
什么是Web Service?
实现ListView控件的行间隔颜色的优化代码
失去信心?还是再度迷惘(二):Mono only is Mono,not .NET never
在Winform中发HTTP请求(调用WebService服务)
.NET中加密和解密的实现方法 3
notNET中加密和解密的实现方法
.NET中加密和解密的实现方法2
mshtml:javascript为HTML文件中的Select添加option
VS.NET解决方案的兼容问题
关于创建快捷方式的小结
使用 GDI+ 进行双缓冲绘图
如何用DataGrid实现根据日期判断是否显示New标志
昨日关注:C-omega vs ADO.net

ASP.NET 中的 AddNew Method Example


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-11-03   浏览: 55 ::
收藏到网摘: n/a


'This example uses the AddNew method to create a new record with the specified 'name. The AddName function is required for this procedure to run.
Sub AddNewX()
Dim dbsNorthwind As Database Dim rstEmployees As Recordset Dim strFirstName As String Dim strLastName As String
Set dbsNorthwind = OpenDatabase("Northwind.mdb") Set rstEmployees = _ dbsNorthwind.OpenRecordset("Employees", dbOpenDynaset)
' Get data from the user. strFirstName = Trim(InputBox( _ "Enter first name:")) strLastName = Trim(InputBox( _ "Enter last name:"))
' Proceed only if the user actually entered something
' for both the first and last names. If strFirstName <> "" and strLastName <> "" Then
' Call the function that adds the record. AddName rstEmployees, strFirstName, strLastName
' Show the newly added data. With rstEmployees Debug.Print "New record: " & !FirstName & _ " " & !LastName ' Delete new record because this is a demonstration. .Delete End With

Else Debug.Print _ "You must input a string for first and last name!"
End If
rstEmployees.Close dbsNorthwind.Close
End Sub
Function AddName(rstTemp As Recordset, _ strFirst As String, strLast As String)
' Adds a new record to a Recordset using the data passed ' by the calling procedure. The new record is then made ' the current record. With rstTemp .AddNew !FirstName = strFirst !LastName = strLast .Update .Bookmark = .LastModified End With
End Function