a sql question

  • Thread starter Thread starter Vicky via DotNetMonster.com
  • Start date Start date
V

Vicky via DotNetMonster.com

Hi, I have a sql question need help. Thanks!

below code works,
------------------------------------------------------------------
mySelectQuery = "Insert into Performance4 (FUNDID, FUNDDATE,[RETURN]
,NAV,FINAL,SOURCE,Periodicity)"+

"VALUES (20222, '" + valDate + "'" +",0.6012," + valNavCl
+",1,'Returs','month')";

myCommand.CommandText = mySelectQuery;
------------------------------------------------------------------
but when I replace 20222 with FundID which is an int variable, and did a
addWatch,
it still display 'FundID', instead a number.
could anyone let me know what is the right syntax?

mySelectQuery = "Insert into Performance4 (FUNDID, FUNDDATE,[RETURN]
,NAV,FINAL,SOURCE,Periodicity)"+

"VALUES (FundID, '" + valDate + "'" +",0.6012," + valNavCl
+",1,'Returs','month')";
 
...
Hi, I have a sql question need help. Thanks!

You *could* concatenate it just like you have done with the other values...
"VALUES (FundID, '" ...

"VALUES (" + FundID + ", '" ...

....but a preferred approach is to use Parameters instead.

Look into the use of e.g. SqlParameter (if you're using SQLServer),
OleDbParameter (if you're using OleDb), etc.


// Bjorn A
 
Bjorn,

Thank you so much for your help, it is working perfectly:)
I love our forum, I am learning things every day.
Thanks!

Vicky
 
Back
Top