i have the below code to extract details from table between two dates but it is raising an exception saying wrong syntax near FROM clause
please suggest the correct solution
(string FromDate,string ToDate)
{
OleDbConnection xlConn = new OleDbConnection(ConnectionString);
using (xlConn)
{
OleDbDataAdapter dAd = new OleDbDataAdapter(@"SELECT tbC.ContID , tbC.Posted_User,
tbC.Content, tbC.PostedDate, tbG.Catg_Name ,tbP.PU_Name FROM
((tblAllContent tbC INNER JOIN tblCatg tbG ON tbC.Catg_ID = tbG.CID)
INNER JOIN tblPU tbP ON tbC.PU_ID = tbP.PID) AND tbc.PostedDate BETWEEN "+FromDate + "AND "+ToDate , xlConn);
DataTable dt = new DataTable();
try
{
xlConn.Open();
dAd.Fill(dt);
return dt;
}
catch (Exception ex)
{
return null;
}
finally
{
xlConn.Close();
xlConn.Dispose();
}
}
}
}
Arul ManivannanPosted Mar 21, 2013, 9:16 AM
Your sql query seems wrong, it is not with C# code.
remove all the brackets in the query which has inner joins
Arul Manivannan