【发布时间】:2014-11-11 00:53:48
【问题描述】:
con = new MySqlConnection(cs);
con.Open();
cmd = new MySqlCommand("SELECT (invoiceNo) as [Invoice No],(invDate) as [inv Date],
(sales.CustomerID) as [Customer ID],(CustomerName) as [Customer Name],
(GrandTotal) as [Grand Total],(TotalPayment) as [Total Payment],(PaymentChange) as
[Payment Change] from sales,customer where sales.CustomerID=customer.CustomerID
and invDate between #" + dtpInvoiceDateFrom.Text + "# And #" +
dtpInvoiceDateTo.Text + "# order by invDate desc", con);
MySqlDataAdapter mySDAp = new MySqlDataAdapter(cmd);
DataSet myDatSet = new DataSet();
mySDAp.Fill(myDatSet, "sales");
mySDAp.Fill(myDatSet, "customer");
dataGridView1.DataSource = myDatSet.Tables["customer"].DefaultView;
dataGridView1.DataSource = myDatSet.Tables["sales"].DefaultView;
错误说明为:You have an error in your SQL syntax check the manual that corresponds to your MySql server version for the right syntax to use near '[InvoiceNo],(invDate) as [inv Date],(sales.CustomerID) as [Customer ID],(Custom' at line 1
【问题讨论】:
-
您是否尝试过任何方法来解决您的问题?错误信息是明确的
-
我已经尝试过语法,我认为它没有错误
-
你在 mysql 中尝试过这个查询而不仅仅是程序吗?
-
请看 Himanshu 的回答,然后请帮我们大家(包括您自己)查找 SQL 和 Vendor Specific Extensions