Link to home
Start Free TrialLog in
Avatar of rito1
rito1

asked on

Example Of Database Connection using ADO Parameters

Hi All

Please could someone provide me with an example ASP database connection string to a SQL Server 2000 database and 1 ADO parameter which loads the data into a recordset.

Many thanks,

Rit
Avatar of Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3]
Flag of Luxembourg image

Avatar of rito1
rito1

ASKER

Hi angellll,

The parameters need to be passed into a stored procedure and also 1 minor detail I missed was - I am using VBScript.. Sorry!

Rit
i dont do it that way i use this way
Set DBatd = Server.CreateObject("ADODB.Connection")
DBcon.Open "Provider=SQLOLEDB; Server=192.168.1.1; Database=database name; UID=userid; PWD=password;"
 
Set Results = DBCon.Execute("select * from table1")

Open in new window

ops line 1 should be Set DBcon
Avatar of rito1

ASKER

Hi,

The reason I was doing it with parameters was that I have been stunk by an SQL injection attack previous so wanted to use ADO parameters to declare them.

Here is the code I have so far... I just can't figure out how to load the data into a recordset:

Set cn = Server.CreateObject("ADODB.Connection")
   cn.Open strDSNless
   Set cmd = Server.CreateObject("ADODB.Command")
   Set cmd.ActiveConnection = cn
   cmd.CommandText = "sp_SELECTCustomers"
   cmd.CommandType = adCmdStoredProc
   
   cmd.Parameters.Append cmd.CreateParameter("Param1", adInteger, _
      adParamInput)
   ' Set value of Param1 of the default collection to 22
   cmd("Param1") = 22
   cmd.Execute
ASKER CERTIFIED SOLUTION
Avatar of Kelvin McDaniel
Kelvin McDaniel
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial