I'm trying to set the value of the sqldatasource
's selectcommand
parameter @ClientID
as in the code below, but it's not working out.
My code:
Dim strCommand = "SELECT caller_id, phone, name, email FROM callers WHERE client_id=@ClientID"
SqlDataSource2.SelectCommand = strCommand
SqlDataSource2.SelectParameters.Add("@ClientID", iClientID)
What am I doing wrong?
The trick to make it work is to remove the paremeter you are trying to use before adding it. The following adapted version of your code should work:
You should not use "@" sign when naming parameters in the code portion of its usage. You should use it only in the SQLCOMMAND string.
Hope it helps.
Here's the VB version:
With the VB.NET version, there wasn't a way to actually set the value, so I set the default value instead. The default value gets used if the value isn't initialized, so since we can't set the value, it'll automatically use the default value anyways.
Never mind...configured the datasource's parameter to take the value of another control..
I have solution for variable from GET to parameter for SelectCommand
You can set your parameter's value like that :