tags:

views:

52

answers:

3

how to pass argument in sql query

ExecuteQuery("Delete from emp where empno = auguement);

+1  A: 

You really need to post more informaton but as a starter....

-- Passing a parameter for a Where clause in a SQL query

Declare @UserId int
Set @UserId = 12

Select * From dbo.Users
Where UserId = @UserId


-- Passing a parameter for use in a Stored Procedure

Declare @UserId int
Set @UserId = 12

Execute dbo.usp_Fetch_User_ById @UserId
Barry
A: 

if you're trying to use the executeQuery Method (SQLServerStatement): http://msdn.microsoft.com/en-us/library/ms378540(SQL.90).aspx

then you jyst use regular string concatenation to build your query string. However you should do a google search on "SQL INJECTION".

KM
A: 

To pass a parameter you need first to have a stored procedure that will consume the parameters:

create procedure sp_AddNumbers
(@int1 int,
@in2 int)
as

  select @in1 + @int2

go

after that call it with code such as

exec sp_Addnumbers @int1=3, @int2=9

or

exec sp_Addnumbers 3, 9
Fatherjack