asp數(shù)據(jù)庫(kù)打開(kāi)問(wèn)題總結(jié)(Asp database opens problem summary)_第1頁(yè)
asp數(shù)據(jù)庫(kù)打開(kāi)問(wèn)題總結(jié)(Asp database opens problem summary)_第2頁(yè)
asp數(shù)據(jù)庫(kù)打開(kāi)問(wèn)題總結(jié)(Asp database opens problem summary)_第3頁(yè)
asp數(shù)據(jù)庫(kù)打開(kāi)問(wèn)題總結(jié)(Asp database opens problem summary)_第4頁(yè)
asp數(shù)據(jù)庫(kù)打開(kāi)問(wèn)題總結(jié)(Asp database opens problem summary)_第5頁(yè)
已閱讀5頁(yè),還剩11頁(yè)未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡(jiǎn)介

1、asp數(shù)據(jù)庫(kù)打開(kāi)問(wèn)題總結(jié)(Asp database opens problem summary)Your ASP book should have: I have a little information, you see useful?In all associated with the Internet technology, the database storage and management is one of the oldest, is currently the most useful, especially when it is endowed with a Web inte

2、rface, storage and management of database has risen to a new height. But with the rapid development of Internet, the first face of the difficulties is based on the traditional technique of CGI interactive pages and Web database access, and other functions to achieve complex, development cycle is lon

3、g, difficult to adapt to todays fast-paced business operation environment. ASP technology is in such demand arises at the historic moment, the ASP (Active Server Pages - Active Server page) is a server-side script execution environment, it through to the *. The ASP file to explain, to build a dynami

4、c, interactive and efficient Web Server application. ASP provides a similar VbSctipt executable script language, and with many built-in objects, which greatly simplifies the Web application development work, this paper emphatically introduces the Web database access technology of ASP.1. ADO overview

5、The ActiveX Data Object is a set of optimized set of objects that access the database, providing the full site database access solution for ASP. The ADO object is executed on the server side, and the client can provide content containing the database information. The client can also read and write t

6、o the database according to the specified permission return parameter. ADO is characterized by fast execution, simple use, low memory consumption, and small footprint.Because ADO accesses the database through ODBC, it can connect to various databases that support ODBC, such as Access, SQL Server, Or

7、acle, Informix, and so on. Before using ADO, you should add the corresponding database driver in ODBC and create the corresponding DSN (data source name). ADO contains many objects, including Connection object and you object is mainly used for controlling access to the database, to establish a datab

8、ase access must first create a Connection object, and then use based on the Connection object you object to complete the database from the operation.2. Connection objectConnection object represents an open Connection with OLE DB data source, it is a little similar to the client/server database appli

9、cations with real network Connection between the server, we can be independent of any other object to create a Connection object. Note that the Connection object is first created before referring to a Connection, whose syntax is as follows, where Connection is the variable that references the Connec

10、tion object: Setconnection = server.creatobject ( adodb.connetcion )The Connection object contains multiple properties, and here are a few common attributes that can only be changed after the Connection object is created and the object is opened. Syntax: Connection. Attribute = attribute value1. Con

11、nectionString a string that contains the connection information,Will be a DSN name or a argument = value string passed to the ConnectionString property, you can specify a data source for Connection object, this property can be set before the Connection is opened, and can also be set on the command O

12、pen. The argument in ADO has the following:Parameter descriptionThe creator of the Providers Connection object, the default value is MSDASQL(Microsoft ODBC Provider for OLE DB)Data Source specifies the ODBC Data Source for this Connection (DSN)User sets the username that opens the connectionThe Pass

13、word setting opens the Password you need when the connection is openedFile Name the File that contains the Connection information specified by the creator(such as the registered data source object)2. The ModeYou can set parameters for the following constants to set the users access to the current co

14、nnection.macrovalueAdModeUnknown 0 not set the operation permission of the database (default)AdModeRead 1 read-onlyAdModeWrite 2 onlyAdModeReadWrite 3 can read and writeAdModeShareDenyRead 4 prohibits other read-only connections to data sourcesAdModeShareDenyWrite 8 prohibits the creation of other w

15、rite-only connections for data sourcesAdModeShareExclusive 12 prohibits other read/write connections to the data sourceAdModeShareDenyNone 16 prohibits any other connection to the data source3. ConnectionTimeout specifies the time to wait for the connection to be established, and if the timeout occu

16、rs, the request is interrupted and the error message is given. Waiting time in seconds, you can assign an integer value to this parameter, the default value is 15 seconds. Setting up the ConnectionTimeout property can give you a hint when the network is crowded or the server is busy, preventing endl

17、ess waiting. If the value of ConnectionTimeout is set to 0, the system waits until the connection is successful.4. CommandTimeout specifies the wait time when the Execute command is executed, and if the timeout occurs, the request is interrupted and the error message is given. Waiting time in second

18、s, you can assign an integer value to this parameter, the default value is 30 seconds.The Open, Close, and Execute methods that use the Connection object can complete all database access actions from establishing a database Connection to manipulating the database and finally closing the Connection.1

19、. The Open Open method opens the physical Connection between the Connection object and the data source, and the syntax is as follows:Connection. Open ConnectionString, UserID, PasswordConnection represents an object variable,Used to refer to an existing Connection object.ConnectionString is optional

20、, meaning the ConnectionString attribute mentioned earlier.The UserID optional variable is a string that contains the user name used to establish the connection.The Password optional variable is a string that contains the Password used to establish the connection.2. Close Close way can Close an open

21、 Connection object, but at this point the Connection object has not been deleted from the memory, we can change it or open the object properties parameters, if you want to release the real object memory space need to set this object to Nothing. If other RecordSet objects are opened based on this Con

22、nection object, all related RecordSet objects will be closed while the Connection object is closed.3. Execute can use Execute to Execute an SQL statement or a stored procedure based on an open Connection object, and can point to the resulting set of results with a RecordSet object. The syntax of the

23、 Execute command is as follows:Connection. The Execute CommandText RecordsAffected, OptionsCommandText string, which contains the SQL statement, table name, or stored procedure to be executed.RecordsAffected optional parameters, a long integer variables, control after the execution, the return value

24、 is the number of records of the manipulation.Options optional parameters describe what manipulation parameters are contained in CommandText, with the following values:macrovalueThe adCmdText 1 CommandText is a command that is described in SQL statementsThe adCmdTable 2 CommandText is a table nameAd

25、CmdStoredProc 4 CommandText is a stored procedureAdCmdUnknown 8 CommandText is an unknown command typeVarious methods of using the Connection object can be used to perform various access actions to the database, such as adding, deleting, updating, and selecting. Heres an example of adding a record t

26、o the table tbl_test, which has two field ids and names, in this case the DSN we use is person.create the Connection object DataConnThe Set DataConn = server. CreateObject ( ADODB. Connection )setting the Mode property value of the DataConn is 3 (read and write)DataConn. Mode = 3the Connection betwe

27、en the Connection object DataConn and the database is established through DSN (person)DataConn. Open the personExecute the SQL statement with the Execute method to add a record in table tbl_test, where the id value is 1The name value is zhang qiang DataConn. Execute ( INSERT INTO tbl_test VALUES ( 1

28、 , zhang qiang )close the Connection objectDataConn. CloseResponse. Write saved% To save the above procedure for an asp file, from the client to access this file will see save, open the database will be found in table tbl_test added a 1, the name is a id value for the b. With the Execute method, we

29、can use different SQL statements to implement various database operations such as add, delete, update, and so on.3. Recordset objectAlthough use the Execute method can implement the various operations of the database, but we are more commonly used in programming or you object, built-in objects of AD

30、O RecordSets are the main interface of the database access, it points to the data in the table a set of records, its a bit similar to the concept of pointer in C language, at any time a RecordSets object only points to a record.The Recordset object provides many methods and properties to facilitate

31、the operation of the database, below are some commonly used Recordset methods and properties.* CursorType should set this property before the Recordset object is opened. It determines the cursor type of the Recordset, and the CursorType can be the following:macrovalueThe adOpenStatic 3 static cursor

32、, which is a copy of the recordset that is accessedNo other user changes to the databaseThe AdOpenDynamic 2 dynamic cursor can see the addition of other users to the databaseAdd, delete, and modify to allow the cursor to move forward or forwardAfter movingThe adOpenKeyset 1 keyword cursor is the sam

33、e as the dynamic cursor, but can only be seenTo other users to update the database, see no add andDelete resultAdOpenForwardOnly 0 cursor forward, with the same static cursor, but the cursor can onlyMove forward* BOF Recordset property, before the current Recordset object points to the first record

34、in the Recordset, the BOF return value is True (-1), otherwise False (0).* EOF Recordset property, when the current Recordset object points to the last record in the Recordset, the BOF return value is True (-1), otherwise False (0).* RecordCount Recordset property, RecordCount returns a long value e

35、qual to the number of Recordset records.* Open before using the Recordset object, first Open a cursor pointing to the record collection using the Open method, and its syntax is as follows: Recordset. Open Source,ActiveConnection CursorType, LockType. The OptionsRecordset recordset object variableThe

36、 Source optional parameter, which is used to select a recordset, can be an SQL statement, table name, or stored procedureActiveConnection optional parameter, a variable represents an open Connection objectThe CursorType optional parameter specifies the cursor type and the default value is 0The LockT

37、ype optional parameter, which specifies the type of lock when editing the recordset is as follows:macrovalueAdLockReadOnly 1 read only, cannot modify record setAdlockin table 2 locks the database to prohibit others when editing the recordsetUser accessAdLockOptimistic 3 locks the database only when

38、the Update method is usedAdLockBatchOptimistic 4 only locks Numbers when the UpdateBatch method is usedAccording to the libraryOption optional parameter, the Option parameter in the Open method of Connection.Note: when using object you can not establish a Connection object, but is passed directly Co

39、nnection parameters in the Open method, in fact this case ADO or create a Connection object, but does not assign it to the object variable. But if you want to create multiple Recordset objects with a Connection object, you must set up an object and assign it to a Connection object variable.* AddNew

40、builds and initializes a new record and points the RecordSet cursor to that record.* Delete deletes the current record that the cursor points to.* Update saves any changes to the current recordset.* MovePrevious Recordset method to point the Recordset object to the previous record.* MoveNext Records

41、et method, which points the Recordset object to the next record.* MoveFirst Recordset method, which points the Recordset object to the first record.* MoveLast Recordset method, which points the Recordset object to the last record.* Close the Recordset method to Close the current Recordset object to

42、free up the system resources.* refer to the data in the database in the form of the Recordset variable ( field name ).Iv. Field objectsEvery you object has a set composed of Field object Fields, each of which a Field of a Field objects are on behalf of you, in the *. The asp file can be referenced u

43、sing the form below the value of these Fields:You. Fields. The Item (0) you. Fields. The Item ( name )You. The Fields (0) you. Fields ( name )You (0) you ( name )You! nameThe recordset represents a recordset object,Name as the Field name in the data sheet, 0 is an integer, a Field object has a number of you, in the reference Field can use the serial number instead of the Field name in this Field, this wi

溫馨提示

  • 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。

最新文檔

評(píng)論

0/150

提交評(píng)論