如何在执行查询后获得两个数据表中的结果?

时间:2016-08-17 07:57:09

标签: c# ado.net

执行结果后出现两个select语句。如何通过c#进入两个不同的数据表?

 using (SqlConnection con = new SqlConnection(sqlConnString))
                {
                    using (SqlCommand cmd = new SqlCommand())
                    {
                        cmd.CommandText = "Exec SPSearchInvoiceList_rjt " + _customerID + "," + _ProjectInchargeID + "," + _projectID +
                            "," + _invoiceType + ",'" + _projectTypes + "'," + _invoiceAmount + ",'" + _invoiceCode +
                            "'," + _invoiceStatusID + ",'" + _invoiceDateFrom + "','" + _invoiceDateTo + "','" +
                            _invoiceRevisedDateFrom + "','" + _invoiceRevisedDateTo + "','" + _invoiceRaiseDateFrom +
                            "','" + _invoiceRaiseDateTo + "'," + Convert.ToInt32(PageIndex) + 1 + "," + pageSize;
                        cmd.Connection = con;
                        con.Open();
                        var datareader = cmd.ExecuteReader();
                        con.Close();
                    }
                }

我正在尝试如上所述。我无法获取记录,但是一旦我在sql server中执行commandtext,我就能获取数据。请帮忙。

0 个答案:

没有答案