
Ado Datatypes in ASP
In Classic ASP, when working with ADO (ActiveX Data Objects) — especially when using ADODB.Command
with parameters — you often need to specify ADO data types.
These types are constants (numeric values) used with CreateParameter
.
? Commonly Used ADO DataTypes
Constant Name | Value | Description | Equivalent SQL Type |
---|---|---|---|
adInteger | 3 | Integer (4 bytes) | INT |
adSmallInt | 2 | Small integer (2 bytes) | SMALLINT |
adTinyInt | 16 | Tiny integer (1 byte) | TINYINT |
adBigInt | 20 | Large integer (8 bytes) | BIGINT |
adVarChar | 200 | Variable-length string | VARCHAR |
adChar | 129 | Fixed-length string | CHAR |
adVarWChar | 202 | Unicode variable-length string | NVARCHAR |
adWChar | 130 | Unicode fixed-length string | NCHAR |
adBoolean | 11 | True/False | BIT , BOOLEAN |
adDate | 7 | Date with time | DATETIME , DATE |
adDBTimeStamp | 135 | Date and time | TIMESTAMP |
adDouble | 5 | Double-precision float | FLOAT , DOUBLE |
adSingle | 4 | Single-precision float | REAL |
adCurrency | 6 | Currency | MONEY |
adDecimal | 14 | Decimal | DECIMAL |
adNumeric | 131 | Numeric | NUMERIC |
adLongVarChar | 201 | Large text | TEXT , LONGTEXT |
adLongVarBinary | 205 | Binary data (e.g. images) | IMAGE , BLOB , VARBINARY(MAX) |
? Example: Using DataType in CreateParameter
Set cmd = Server.CreateObject("ADODB.Command")Set cmd.ActiveConnection = conncmd.CommandText = "INSERT INTO Users (Name, Age, IsActive) VALUES (?, ?, ?)"cmd.CommandType = 1 ' adCmdTextcmd.Parameters.Append cmd.CreateParameter("Name", 200, 1, 50, "John") ' adVarCharcmd.Parameters.Append cmd.CreateParameter("Age", 3, 1, , 30) ' adIntegercmd.Parameters.Append cmd.CreateParameter("IsActive", 11, 1, , True) ' adBoolean
? Tips
Direction:
1 = adParamInput
,2 = adParamOutput
Always match ADO data types with the expected column types in your database.
adVarChar
andadVarWChar
require a length parameter.
Let me know if you want the full list of all ADO types or just those relevant to a specific database (like SQL Server or Access).