ASP 3.0 Declare ADO constants without inclusion. Includes ADOVBS.inc

I wrote a simple script form handler using ASP3.0 / VBScript and would like to add the entered data (via the Internet) to the Access database located on my server. I use the OLEDB method to connect as follows:

Cst = "PROVIDER=Microsoft.Jet.OLEDB.4.0;" & _
"DATA SOURCE=" & Server.MapPath("DataBase.mdb")

Dim Conn
Set Conn = CreateObject("ADODB.Connection")
Conn.Mode = 3

Conn.Open Cst

Blah Blah Blah...

I currently have a file called ADOVBS.inc which is included at the top, but would like to drop it because I consider it inefficient and wasteful. I would like to define constants as I need them, but I do not know how to do this. What ADO constants do I need to define and where? The book I use basically says: "Forget it, the pound includes those 400 or so mounds there and don't ask stupid questions!"

Any concrete examples / help are appreciated.

Thank,

+3
3

. ( global.asa)

<!--
   METADATA    
   TYPE="TypeLib"    
   NAME="Microsoft ActiveX Data Objects 2.5 Library"    
   UUID="{00000205-0000-0010-8000-00AA006D2EA4}"    
   VERSION="2.5"
-->

adovbs , .

Const adCmdText = 1      'Evaluate as a textual definition    
Const adCmdStoredProc = 4 'Evaluate as a stored procedure
+9

, " -, 400 boogers !" :)

:

.ASP
dbHelper.asp

DB, :

''// run a query and returns a disconnected recordset
Function RunSQLReturnRS(sqlstmt, params())
    On Error Resume next

    ''//Create the ADO objects
    Dim rs , cmd
    Set rs = server.createobject("ADODB.Recordset")
    Set cmd = server.createobject("ADODB.Command")

    ''// Init the ADO objects  & the stored proc parameters
    cmd.ActiveConnection = GetConnectionString()
    cmd.CommandText = sqlstmt
    cmd.CommandType = adCmdText

    collectParams cmd, params

    ''//Execute the query for readonly
    rs.CursorLocation = adUseClient
    rs.Open cmd, , adOpenForwardOnly, adLockReadOnly
    If err.number > 0 then
        BuildErrorMessage()
        exit function
    end if

    ''//Disconnect the recordset
    Set cmd.ActiveConnection = Nothing
    Set cmd = Nothing
    Set rs.ActiveConnection = Nothing

    ''//Return the resultant recordset
    Set RunSQLReturnRS = rs

End Function

, ado , .

0

The corresponding list of constants can be found here: http://www.4guysfromrolla.com/ASPScripts/PrintPage.asp?REF=%2Fwebtech%2Ffaq%2FBeginner%2Ffaq7.shtml

I will also copy it here:

'---- CursorTypeEnum Values ----
Const adOpenForwardOnly = 0
Const adOpenKeyset = 1
Const adOpenDynamic = 2
Const adOpenStatic = 3

'---- CursorOptionEnum Values ----
Const adHoldRecords = &H00000100
Const adMovePrevious = &H00000200
Const adAddNew = &H01000400
Const adDelete = &H01000800
Const adUpdate = &H01008000
Const adBookmark = &H00002000
Const adApproxPosition = &H00004000
Const adUpdateBatch = &H00010000
Const adResync = &H00020000

Should be enough to insert / select / update records in the database.

-1
source

Source: https://habr.com/ru/post/1795283/


All Articles