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

ASP.NET
asp.net GridView控件中模板列CheckBox全选、反选、取消
asp.net GridView 删除时弹出确认对话框(包括内容提示)
asp.net DropDownList 三级联动下拉菜单实现代码
asp DataTable添加列和行的三种方法
Asp.net 页面调用javascript变量的值
asp.net 长文章通过设定的行数分页
asp.net 定时间点执行任务的简易解决办法
asp.net 页面延时五秒,跳转到另外的页面
asp.net 动态输出透明gif图片
asp.net DataList与Repeater用法区别
asp.net Javascript获取CheckBoxList的value
asp.net程序在调式和发布之间图片路径问题的解决方法
asp.net下生成英文字符数字验证码的代码
asp.net 页面版文本框智能提示JSCode (升级版)
ASP.NET URL伪静态重写实现方法
ASP.NET 2.0 中Forms安全认证
asp.net 动态添加多个用户控件
asp.net Repeater显示父子表数据,无闪烁
asp.net 无法获取的内部内容,因为该内容不是文本 的解决方法
asp.net GridView排序简单实现

ASP.NET 中的 AddNew Method Example


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