Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Parameters without stored procedure

Status
Not open for further replies.

cthaxter

Programmer
Aug 2, 2001
71
US
I've tried in vain to search for examples using the parameter object of ADODB without using a stored procedure. How do you use a SQL statement in one's code, using parameters?

See this Microsoft Support topic to see what I mean:
Note these two lines:

objCmd.CommandText = "SampleQuery"
objCmd.CommandType = adCmdStoredProc

I want to know what the SampleQuery looks like as an SQL statement, such that objCmd.CommandText will be a SQL statement with multiple parameters in the WHERE clause, and objCmd.CommandType will be adCmdText.

Then, I want to know how to add the various parameters and their values, making sure this value corresponds to that part of the WHERE clause, and so forth:

Set objParam1 = objCmd.CreateParameter("@productid" , adInteger, adParamInput, 0, 0)
objCmd.Parameters.Append objParam1
Set objParam2 = objCmd.CreateParameter("@productamount" , adInteger, adParamInput, 0, 0)
objCmd.Parameters.Append objParam2

I hope you see what I mean. Any help would be greatly appreciated.

Christopher
 
I did a similar thing with an access query in a test environment before using a stored procedure in SQL2000

here is some sql I used

SELECT ClientData.ClientName, Country.CountryDescription
FROM ClientData INNER JOIN Country ON ClientData.CountryID = Country.CountryID
WHERE Country.CountryDescription Like [@country]
'nb @country is text
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top