首页 | 免费域名 | 个人服务器 | 一流信息监控拦截系统 | 虚拟主机知识库 | ASP 空间 | ASP技术大全 | 下载中心 | 客户服务中心
  7i24 > ASP技术大全 > ASP与数据库 >
    7i24 .Com  
  如何用ASP远程在数据库中创建Table

7i24.Com不停为您服务
如何用ASP远程在数据库中创建Table

Dim objRS
Set objRS = Server.CreateObject( "ADODB.Recordset" )
objRS.CursorLocation = adUseClient
 

objRS.Fields.Append "Product", adBSTR
objRS.Fields.Append "Quantity", adInteger
objRS.Fields.Append "Unit Price", adCurrency
 

objRS.Open
objRS.AddNew
An empty record now exists; you just need to set the values.

objRS.Fields( "Product" ).value = "1969 Camero RS"
objRS.Fields( "Quantity" ).value = 3
objRS.Fields( "Unit Price" ).value = 2000.40
And finally Update() is called to save the changes.

objRS.Update
 

ADO Added Value
If that were all, using ADO in this way would be no better than using
arrays. However, you now get to use all that great functionality
built into ADO. Let's look at some specific examples.

Methods
There are many methods available in ADO used for data manipulation. A
popular feature is sorting. Instead of writing code to sort an array
you can store the data in an ADO Recordset object and sort it.

objRS.Sort = "Product"
This creates a temporary index based on the Product field, so when
the records are accessed they will be returned in a sorted order.

Streaming
Data in a recordset can be streamed out as a string. An example of
its use is building a comma-delimited file to import into Excel. Here
is an example:

asString = objRS.GetString( adClipString, , "," )
The method GetString() starts at the current cursor position, so be
sure to call MoveFirst if you intend to stream all the records. The
parameters to GetString() allow you to control the number of rows to
convert, the column delimiter, the row delimiter and the expression
used for a NULL field.

Persistence
Persisting data to a file so that a data structure can be
reconstructed later is tedious if you are using standard data types,
since you have to create your own persistence mechanism. ADO has
persistence built in so you get it for free. To write your recordset
to a file just call Save() .

objRS.Save "theOrder.dat", adPersistADTG
The file type in this case is "Advanced Data Tablegram" format. This
is a proprietary Microsoft format, so it is only really useful for
storing a recordset in a file. The only other option is adPersistXML.

To reconstruct the recordset from the file just do the following:

Dim objRS2
Set objRS2 = Server.CreateObject( "ADODB.Recordset" )
objRS2.Open "theOrder.dat"



  2002年1月7日  阅读 590 次  发送此页给朋友  来源:    版权争议  删除

相关文章:   近期热点:

上一篇: SQL数据库的一些攻击
下一篇: 用ASP实现从SQL Server导出数据到Access或Excel文件
返回上一层...
搜索:

(C)2004-2022 7i24.Com 保留所有权利