How to immerse variable into SQL statement
Hi,
I have the SQL statement and don't know hot to immerse a variable into it. Can someone help please? Example: SqlCommand cmd = new SqlCommand("insert into Vydaje values ('variable', '2008-05-19', 150, 9788071698609)", conn); And I need to insert the variable exp[0] instead the word variable in the statement.
Thanks.
Regards, Petr.
4 Answers
Know the answer? Post it. Somebody with the same question will find it here.

Ryan AlfordRank #1,411 · 1.2K reputationPosted May 19, 2008, 10:52 AM EDT
Petr Puncochar12 reputationPosted May 19, 2008, 12:01 PM EDT
Ryan AlfordRank #1,411 · 1.2K reputationPosted May 19, 2008, 12:46 PM EDT
SqlCommand cmd = new SqlCommand("insert into Vydaje values ('" + exp[0].ToString() + "', '2008-05-19', 150, 9788071698609)", conn);
Petr Puncochar12 reputationPosted May 19, 2008, 1:01 PM EDT