//Begin Sample
con = new SqlConnection(YourConnectionString);
con.Open();
string CommandText = "usp_getFooBar";
cmd = new SqlCommand(CommandText,con);
cmd.CommandType = StoredProcedure; //Change to Text for an adhoc query
cmd.Parameters.Add(new SqlParameter("@ID", System.Data.SqlDbType.Int );
cmd.Parameters["@ID"].Value = Request.Form("someIntValue");
SqlDataReader rdr = cmd.ExecuteReader();
//close stuff as usual
//End SampleChip Andrews www.sqlsecurity.com
David,
Actually, to nitpick your comment a bit, stored procedures usually have typed input variables:
create procedure foo ( a int, b varchar(20) ) as ...
At least in MSSQL, you'd have to do something bad like use sp_executesql or some other function that will re-form a complete sql query and pass that to the interpreter. As long as you do more sensible stuff like:
insert into table (name, age) values (@b, @a)
you should be fine.
Michael Scovetta Computer Associates Senior Application Developer