Want to update @parameter in select

  • Thread starter Thread starter Mike
  • Start date Start date
M

Mike

I have a dataadapter that has "where field_name = @parameter". I need to
replace the @parameter and then call fillschema and then fill. I've looked
too long in the help files and haven't been able to find the code.
 
Found it. I was using ( instead of [. Darn I hate when I'm scanning the
code and I am reading the VB and not the C#.

sqlDataAdapter1.SelectCommand.Parameters["@tracking_cd"].Value = myKey;
 
Hi Mike:

I'm not sure I understand the problem for sure but I'll take a stab. To set
the value of @parameter you need to reference it in the command's paramaters
collection (assuming it's been added, if not, you'll need to add it)

myCommand.Parameters.Add("@parameter", SqlDbType.Varchar, 50).Value =
"Whatever";

//I'm assuming this is SQL Server b/c the @ symbol, but the same logic holds
for other providers. Moreover, there are multiple constructors for adding
params, you don't necessarily need to use this one.

If it's already added, all you need to do is
myCommand.Parameters("@parameter").Value = "whatever";

If this isn't what you need, can you tell me a little more about the end
game and hopefully I can be of more help.

Cheers,

Bill
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top