con = new OleDbConnection(cs.ConDB);
con.Open();
cmd =new OleDbCommand(@"SELECT RTRIM(TASK_ASSIGNMENT.Task_ID)AS [Task ID],
RTRIM(TASK_ASSIGNMENT.Complaint_ID) AS [Complaint ID],
RTRIM(TASK_ASSIGNMENT.Cust_ID) AS [Customer ID],
RTRIM(TASK_ASSIGNMENT.Emp_ID) AS [Employee ID],
RTRIM(TASK_ASSIGNMENT.Assign_Date) AS [Assign Date],
RTRIM(TASK_ASSIGNMENT.Deadline) AS [Dead Line],
RTRIM(TASK_ASSIGNMENT.Task_Status) AS [Task Status],
RTRIM(TASK_ASSIGNMENT.Status_Date) AS [Status check Date],
RTRIM(EMP_DETAILS.Name) AS [Employee Name],
RTRIM(CUST_DETAILS.Name) AS [CustomerName],
RTRIM(CUST_DETAILS.Mobile_no) AS [Customer's Mob],
RTRIM(COMPLAINT_DETAILS.Complaint_Type) AS [Complaint Type],
RTRIM(COMPLAINT_DETAILS.Complaint_Description) AS [Complaint Description]
FROM TASK_ASSIGNMENT
INNER JOIN EMP_DETAILS ON TASK_ASSIGNMENT.Emp_ID = EMP_DETAILS.Emp_ID
INNER JOIN CUST_DETAILS ON TASK_ASSIGNMENT.Cust_ID = CUST_DETAILS.Cust_ID
INNER JOIN COMPLAINT_DETAILS ON TASK_ASSIGNMENT.Complaint_ID = COMPLAINT_DETAILS.Complaint_ID", con);
//new OleDbCommand("SELECT RTRIM(TASK_ASSIGNMENT.Task_ID) AS [Task ID],RTRIM(TASK_ASSIGNMENT.Complaint_ID) AS [Complaint ID],RTRIM(TASK_ASSIGNMENT.Cust_ID) AS [Customer ID], RTRIM(TASK_ASSIGNMENT.Emp_ID) AS [Employee ID], RTRIM(TASK_ASSIGNMENT.Assign_Date) AS [Assign Date], RTRIM(TASK_ASSIGNMENT.Deadline) AS [Dead Line],RTRIM(TASK_ASSIGNMENT.Task_Status) AS [Task Status], RTRIM(TASK_ASSIGNMENT.Status_Date) AS [Status check Date],RTRIM(EMP_DETAILS.Name) AS [Employee Name],RTRIM(CUST_DETAILS.Name) AS [Customer Name], RTRIM(CUST_DETAILS.Mobile_no) AS [Customer's Mob], RTRIM(COMPLAINT_DETAILS.Complaint_Type) AS [Complaint Type],RTRIM(COMPLAINT_DETAILS.Complaint_Description) AS [Complaint Description] FROM TASK_ASSIGNMENT INNER JOIN EMP_DETAILS ON TASK_ASSIGNMENT.Emp_ID = EMP_DETAILS.Emp_ID INNER JOIN CUST_DETAILS ON TASK_ASSIGNMENT.Cust_ID = CUST_DETAILS.Cust_ID INNER JOIN COMPLAINT_DETAILS ON TASK_ASSIGNMENT.Complaint_ID = COMPLAINT_DETAILS.Complaint_ID", con);
OleDbDataAdapter myDA = new OleDbDataAdapter(cmd);
DataSet myDataSet = new DataSet();
myDA.Fill(myDataSet, "EMP_Details");
myDA.Fill(myDataSet, "Complaint_Details");
myDA.Fill(myDataSet, "Task_Assignment");
myDA.Fill(myDataSet, "Cust_Details");
dataGridView1.DataSource = myDataSet.Tables["EMP_details"].DefaultView;
dataGridView1.DataSource = myDataSet.Tables["Task_Assignment"].DefaultView;
dataGridView1.DataSource = myDataSet.Tables["Cust_Details"].DefaultView;
dataGridView1.DataSource = myDataSet.Tables["Complaint_Details"].DefaultView;
con.Close();
答案 0 :(得分:2)
添加适当的打开/关闭括号以隔离连接的不同部分(这似乎是MS-Access所需的怪癖)
cmd =new OleDbCommand(@"SELECT ......
....
FROM ((TASK_ASSIGNMENT INNER JOIN EMP_DETAILS
ON TASK_ASSIGNMENT.Emp_ID = EMP_DETAILS.Emp_ID)
INNER JOIN CUST_DETAILS
ON TASK_ASSIGNMENT.Cust_ID = CUST_DETAILS.Cust_ID)
INNER JOIN COMPLAINT_DETAILS
ON TASK_ASSIGNMENT.Complaint_ID = COMPLAINT_DETAILS.Complaint_ID
但是,请记住,此查询只返回一个表,您尝试调用4次Fill方法不会产生4个不同的表
答案 1 :(得分:0)
尝试在打开的括号和查询的开头双引号之间加一个@,如下所示:
cmd =new OleDbCommand(@"SELEC..