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

ASP.NET
使用NUnit进行单元测试
[FxCop.设计规则]1. 抽象类不应该拥有构造函数
遍历XML文档返回二维数组(ASP)(更新版)
c#中的interface abstract与virtual
[VB.NET] Single & Double
asp.net验证码生成类(参考)
JAVA开发者应该去的20个英文网站 [摘]
C#中关于GDI+输出的问题
XML 命名空间提供了一种避免元素命名冲突的方法。
VS.NET 2005 Beta 2初体验(3)—操作SQL Mobile数据库
VS.NET 2005 Beta 2初体验(1)-用C#开发Managed代码
VS.NET 2005 Beta 2初体验(2)-用C++开发Native代码
VS.NET 2005 Beta2初体验(4)-Notification控件
XmlHttp异步获取网站数据的例子
利用C#编写一个简单的抓网页应用程序
C#中结构与类的区别
在.NET中实现彩色光标,动画光标和自定义光标
C#2.0新特性探究之模拟泛型和内置算法
C#2.0 新特性探究之委托与匿名委托
获取本机的本地上网IP地址

ASP.NET 中的 AddNew Method Example


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-11-03   浏览: 65 ::
收藏到网摘: 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