0

I'm going to insert a Unicode text into SQL Server database by ADOQuery . My text is stored in k_message WideChar variable. I know that I have to prefix 'N' for Unicode actions in SQL Server, But in this case How to apply this letter for k_message column? on the other hand ADOQuery only gets non-Unicode text SQL string and I have to use parameter instead. With the following code I have received error:

Incorrect Syntax near @P1.

My Programming Environment is: Borland C++ Builder 6

txt="insert my_table(ksource,ksubject,kdate,ktime,kmessage) values ('SMS','"+
                                              fsubject+"','"+
                                              fdate+"','"+
                                              ftime+"',N :k_message)";
DMod1->ADOQuery2->Close();
DMod1->ADOQuery2->Prepared=true;
DMod1->ADOQuery2->SQL->Clear();
DMod1->ADOQuery2->SQL->Add(txt);
DMod1->ADOQuery2->Parameters->ParamByName("k_message")->Value=k_message;
DMod1->ADOQuery2->ExecSQL();
shA.t
  • 16,580
  • 5
  • 54
  • 111
Majid
  • 21
  • 3

1 Answers1

0

I think this should work

txt="insert my_table(ksource,ksubject,kdate,ktime,kmessage) values ('SMS',N'"+
                                              fsubject+"',N'"+
                                              fdate+"',N'"+
                                              ftime+"N',N :k_message)";
M.Ali
  • 67,945
  • 13
  • 101
  • 127