Click here to Skip to main content
15,906,947 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have a user control whose events create a variable which is then used to search a database. could someone share the code necessary to pass parameters to an ultralite sybase database? i've tried CommandText = "select name, password from dtident where name =@token" and parameters.add(parametername,value) but keep getting, 'syntax error at @'.
Posted
Comments
Sandeep Mewara 14-Sep-10 12:03pm    
Update from OP:
parameters token;
select name, password from dtident where name = {token};

encapsulate token in '' i.e pass your parameter as 'token' to return the values. hope someone else finds this useful

1 solution

I've not tried this with sybase, but it should be common to all SQL systems.
Make sure your "parametername" in the Parameters.Add statement is identical to that used in your SQL Text:
string CommandText = "select name, password from dtident where name=@token";
cmd.Parameters.AddWithValue("@token",value);
You could use Parameters.Add but that is more complex:
cmd.Parameters.Add("@token",DbType.Integer).Value = value;
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900