Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# SQL WinForm queries
When i run this query it's give an error "Join expression not supported."
 
My C# code with connection is :
 
private void button1_Click(object sender, EventArgs e)
        {
            OleDbConnection con = new OleDbConnection("Provider=Microsoft.jet.oledb.4.0; data source=" + Application.StartupPath + @"\DataInfo1.mdb;Persist Security Info=true;User Id='Admin'; password=;");
            con.Open();
            OleDbDataAdapter da = new OleDbDataAdapter("SELECT ct.custID, c.custName, c.custAdd,ct.custTranDate,ct.custTranType,ct.custPaidAmt,ct.custDueAmt, c.custArea FROM custTransaction ct left JOIN custDetails c ON ct.custID = c.custID and(ct.custTranDate BETWEEN #2/28/13# AND #3/1/13# and ct.custID='CUST-000002')", con);            
           DataSet ds = new DataSet();
           da.Fill(ds);
           CrystalReport1 cr = new CrystalReport1();
           cr.SetDataSource(ds);
            this.crystalReportViewer1.ReportSource = new CrystalReport1();
            this.crystalReportViewer1.Show();
        }
 
I'm using MSAccess in back end database..
how to fix it???
 
thanks in Advanced..
Posted 6-Mar-13 4:24am

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

ON ct.custID = c.custID and(ct.custTranDate BETWEEN
I see there is no space between and and bracket.
 
Try:
OleDbDataAdapter da = new OleDbDataAdapter("SELECT ct.custID, c.custName, c.custAdd,ct.custTranDate,ct.custTranType,ct.custPaidAmt,ct.custDueAmt, c.custArea FROM custTransaction ct left JOIN custDetails c ON ct.custID = c.custID and (ct.custTranDate BETWEEN #2/28/13# AND #3/1/13# and ct.custID='CUST-000002')", con);   

Further, use parameterized query to pass values. That way you can pass the values of date and id as per defined easily without creating any syntax error.
 
Further, you should put the search criteria as WHERE clause, like:
OleDbDataAdapter da = new OleDbDataAdapter("SELECT ct.custID, c.custName, c.custAdd,ct.custTranDate,ct.custTranType,ct.custPaidAmt,ct.custDueAmt, c.custArea FROM custTransaction ct left JOIN custDetails c ON ct.custID = c.custID WHERE ct.custID='CUST-000002' AND ct.custTranDate BETWEEN #2/28/13# AND #3/1/13#)", con);    
  Permalink  
Comments
Jayanta Chatterjee at 6-Mar-13 10:17am
   
Sir, Thanks a Lottttt...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



Advertise | Privacy | Mobile
Web04 | 2.8.1411022.1 | Last Updated 6 Mar 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100