Ben,
It isn't too complicated, but it can certainly be confusing at first.
Personally I'm not the biggest fan of design time stuff, I realize it's much
quicker and simpler, but if you're like me, you like having a fine grain
control. Additionally, you learn a lot more by doing it yourself.
Having said that, I'm not 100% sure what step you are having a hard time
with. Is it simply getting a value from the querystring? or assigning it as
a parameter? Without knowing what you have, I'll show you a basic way of
doing the entire thing:
(code not compiled, typing it off the top of my head)
Sub Page_Load
dim id as integer = 0
if Request.QueryString("userId") is nothing then
id = -1 'some default value
else
id = Convert.ToInt32(Request.QueryString("userId")) 'could throw an
exception if it isn't a valid it, so you might wanna try/catch this
end if
dim connection as new SqlConnection(CONNECTION_STRING)
dim command as new SqlCommand(connection, "STORED_PROCEDURE_NAME")
command.commandType = commandType.StoredProcedure
command.Parameters.Add("@UserId", SqlDbType.Int).Value = id 'here's where
you assign the variable to the sproc
dim ds as new DataSet
dim da as new SqlDataAdapter(command)
try
connection.Open()
da.Fill(ds)
finally
connection.dispose()
command.dispose()
da.dispose()
end try
you now have a DataSet (ds) with the data..
The above code should be moved into a utility function, which returns a
dataset, so that you can reuse it, but other than that, all should be good.
lemme know if anything specific irkes you.
Karl
--
MY ASP.Net tutorials
http://www.openmymind.net/
"Ben Barnes" <be**********@hotmail.com> wrote in message
news:4a*************************@posting.google.co m...
hi,
I'm a relative newbie to .net but have been an asp developer for a few
years. I'm starting the slow and somehwat painful process of learning
how to do everything I used to do in asp in .net.
i'm using visual studio and am simply trying to do the following:
Pass a value into a stored procedure or a sql query which has been is
passed via a querystring.
I've achieved this by setting the value of the parameter in the
desinger generated code but I would like to be able to handle this in
the page_load. I'd like to check for the existence of a paramater and
pass this value to the query.
I'm sure it's really easy, it certainly is in classic asp but i'm
really struggling with this one.
Anyone help?