Last post Aug 25, 2016 09:17 AM by vijaypwr61
Aug 24, 2016 02:08 AM|vijaypwr61|LINK
I tried this
=>OleDbCommand cmd2 = new OleDbCommand("Insert Into Sample1(Total) Select Sub1 From Sample2 Union Select Sub2 From Sample2", Econ);
but getting error like
=>"Syntax error in FROM clause. "
Am I missing somthing here?
Aug 24, 2016 05:28 AM|JLaxmi|LINK
Instead of using OleDb why don't you try using sqlclient. I tried the same with sqlclient and it worked fine.
Aug 24, 2016 07:35 AM|vijaypwr61|LINK
Thank you but Mam, I m using ACCESS database so.
And mam the following is working Perfectlty
"OleDbCommand cmd1 = new OleDbCommand("Insert Into Sample1([AdmNo],[SName],[RollNo],[Faculty],[AdmYear]) Select AdmNo, SName, RollNo, Faculty, AdmYear From Sample2 Where Faculty='"+EFaculty.SelectedValue.ToString()+"' AND Puc1='PUC-I' AND AdmYear='"+EYear.SelectedValue.ToString()+"'",
Aug 25, 2016 08:31 AM|techviju|LINK
OleDbCommand cmd2 = new OleDbCommand(" Insert Into Sample1(Total)
select Total from
(Select Sub1 as Total From Sample2
Select Sub2 as Total From Sample2)q ", Econ);
Aug 25, 2016 09:16 AM|Chris Zhao|LINK
You need use parameterized queries to query SQL Server database in order to avoid SQL Injection attacks.
Aug 25, 2016 09:17 AM|vijaypwr61|LINK
Oh Thank you Sir.
Now I tried this (Concatenate)
=>OleDbCommand cmd2 = new OleDbCommand(" Insert Into Sample1([Total]) Select Sub1 & '-' & Sub2 From Sample2) ", Econ);
and working fine,
I m beginner so getting trouble.
Thanks to all