Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/81.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 在中继器中放置一个中断_C#_Sql - Fatal编程技术网

C# 在中继器中放置一个中断

C# 在中继器中放置一个中断,c#,sql,C#,Sql,我有两个中继器。第一个返回所有客户交易记录,而第二个返回在系统中为该特定客户输入的注释。问题在于,当客户在特定月份拥有多张票据时,付款交易表将根据票据表重复交易。例如,如果note表中有3月10日的notes,那么我将在payment表中看到10笔交易(都是相同的)。如何生成与付款交易分开的票据 谢谢大家! protected void FillNotesTable() { string connection = @"Data Source=###; User ID

我有两个中继器。第一个返回所有客户交易记录,而第二个返回在系统中为该特定客户输入的注释。问题在于,当客户在特定月份拥有多张票据时,付款交易表将根据票据表重复交易。例如,如果note表中有3月10日的notes,那么我将在payment表中看到10笔交易(都是相同的)。如何生成与付款交易分开的票据

谢谢大家!

  protected void FillNotesTable()
    {

        string connection = @"Data Source=###; User ID = ###; Password=###; Initial Catalog = ###; Persist Security Info=True; Integrated Security=True";
        using (SqlConnection conn = new SqlConnection(connection))
        using (SqlCommand cmd = new SqlCommand("GetCurrentCustomerNotes", conn))
        {
            cmd.CommandType = CommandType.StoredProcedure;

            if (conn.State != ConnectionState.Open)
                conn.Open();

            // User input
            cmd.Parameters.Add("@CID", SqlDbType.VarChar);
            cmd.Parameters["@CID"].Value = tbCustomerID.Text;

            repeaterNotes.DataSource = cmd.ExecuteReader();
            repeaterNotes.DataBind();

            conn.Close();
            conn.Dispose();
        }
}


在我看来,你好像要拿回一个数据表,但应该要拿回两个——一个主数据表和一个药膏,然后使用一个。谢谢你,大卫。我忘了提到Notes表与设备无关。也许这会帮助你提出其他建议。数据库中的Notes表只有客户ID,用于识别哪个客户拥有该Notes。付款表作为单位和客户id,我创建了两个不同的存储过程来获取数据。我想我想要的是在达到数据库中找到的事务数时中断payments表中继器。希望这更清楚。
 protected void GetDataUnit()
    {
        string userName = Environment.UserName;
        userName = Request.Cookies["###"]["User"];
        tbFPN.Text = userName;

        string connection = @"Data Source=###t; User ID = ###; Password=###; Initial Catalog = ###; Persist Security Info=True; Integrated Security=True";
        using (SqlConnection conn = new SqlConnection(connection))
        using (SqlCommand cmd = new SqlCommand("GetCurrentCustomerByUnit", conn))

            try
            {

                cmd.CommandType = CommandType.StoredProcedure;

                if (conn.State != ConnectionState.Open)
                    conn.Open();

                // User input
                cmd.Parameters.Add("@UN", SqlDbType.VarChar);
                cmd.Parameters["@UN"].Value = tbSearchNumber.Text;
                cmd.Parameters.Add(new SqlParameter("@FPN", userName));

                // Return info
                SqlDataReader objDR;
                objDR = cmd.ExecuteReader();

                if (objDR.Read())
                {
                    tbCustomerID.Text = objDR["ID"].ToString();
                    tbCertNumber.Text = objDR["Cert_Number"].ToString();
                    tbReturnUnit.Text = objDR["Unit_Number"].ToString();
                    tbReturnName.Text = objDR["Customer_Name"].ToString();               
                    tbReturnAddress.Text = objDR["Address"].ToString();
                    tbReturnCity.Text = objDR["City"].ToString();
                    tbReturnState.Text = objDR["State_Abbr"].ToString();
                    tbReturnZipCode.Text = objDR["ZIP_Code"].ToString();
                    tbReturnPhone.Text = objDR["Phone_Number"].ToString();
                    tbReturnEmail.Text = objDR["Email_Address"].ToString();

                }
                objDR.Close();

                repeaterPayments.DataSource = cmd.ExecuteReader();
                repeaterPayments.DataBind();
            }

            catch (Exception ex)
            {
                lblMessage1.Text = ex.Message;
                lblMessage1.Visible = true;
            }

            finally
            {
                conn.Close();
                conn.Dispose();
            }
    }