ITPub博客

首页 > Linux操作系统 > Linux操作系统 > 如何用ASP远程在数据库中创建Table (转)

如何用ASP远程在数据库中创建Table (转)

原创 Linux操作系统 作者:jcszjswkzhou 时间:2019-05-27 09:24:04 0 删除 编辑
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"


来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/10294527/viewspace-124478/,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2007-08-29

  • 博文量
    2772
  • 访问量
    2037324