- UID
- 10108
- 积分
- 5956
- 精华
- 贡献
-
- 威望
-
- 活跃度
-
- D豆
-
- 在线时间
- 小时
- 注册时间
- 2002-9-17
- 最后登录
- 1970-1-1
|
发表于 2018-3-9 10:23:11
|
显示全部楼层
------------------------------------------------------------------
Examples (written in VBScript on Active Server Pages)
----------------------
Example: Connecting and disconnecting from a database
Note: Disconnection is always recommended to free up resources.
set myObject = Server.CreateObject("WMIDB.MySQL")
m_iResult = myObject.OpenConnection("HostName", "Port", "UserName", "Password", "Database")
myObject.CloseConnectionID m_iResult
Note: m_iResult is a return value, > 0 = ConnectionID, < 0 = Error
----------------------
Example: Opening and closing a recordset
Note: Closing a recordset is not mandatory
if myObject.OpenRecordset("Handle Name", "SQL Statement Returning Rows") then
Do work here
myObject.CloseRecordset "Handle Name"
end if
Note: SQL Statement can only be 8192 characters in length. Handles only unique to 100 characters.
m_iResult is a return value, zero (0) on success, one (1) on failure
----------------------
Example: Refreshing a recordset
Note: Retrieves latest data from database and moves you to first row again.
myObject.Refresh "Handle Name"
----------------------
Example: Checking Recordset Bounds
Note: There are functions to allow you to check the EOR and BOR
values returned are true and false. If recordset is empty
both will return true.
m_iResult1 = myObject.EOR("Handle Name")
m_iResult2 = myObject.BOR("Handle Name")
if m_iResult1 and m_iResult2 then
Recordsets are empty
end if
----------------------
Example: Navigation
Note: Functions will move recordset through results
myObject.MoveNext "Handle Name"
myObject.MovePrevious "Handle Name"
myObject.MoveFirst "Handle Name"
myObject.MoveLast "Handle Name"
----------------------
Example: Retrieving values
Note: These functions allow you to retrieve particular values from within the current row.
m_varReturn = myObject.GetFieldByName("Handle Name", "Column Name")
m_varReturn = myObject.GetFieldByIndex("Handle Name", IntegerRepresentingOrder)
Note: The GetFieldByIndex function will allow you to retrieve the column from the row
by the order in which it was retrieved, 0 -> N-1
----------------------
Example: Executing miscellaneous commands (Only available in full version)
Note: This function will allow you to execute any SQL command without storing the
rows (if any) coming back. For use with CREATE, UPDATE, INSERT, DELETE, DROP, ALTER, etc.
m_iResult = myObject.Execute("SQL Statement to Run")
Note: This will return a true for successful sends and false for failed communication.
|
|