请教一个SQL的语法问题请大神帮我纠正下,多谢多谢
表结构如下,现在是传输的时候,如单号为B0115051400007的单据,第一笔为22,第二笔为10,我需要传输的是第一笔22第二笔为10-22=-12,现在传过去还是1...
表结构如下,现在是传输的时候,如单号为B0115051400007的单据,第一笔为22,第二笔为10,我需要传输的是第一笔22第二笔为10-22=-12,现在传过去还是10,请大神帮我纠正下,多谢多谢
String constr = ConfigurationManager.ConnectionStrings["connectIssrestv6"].ConnectionString.ToString();
SqlConnection con = new SqlConnection(constr);
SqlConnection con2 = new SqlConnection(constr);
string sqlQueryPayAmount = "select pay.ch_payno, pay.ch_billno, pay.dt_operdate, pay.payamount from( select ch_payno, ch_billno, dt_operdate, (num_cost - num_discount) as payamount from cybr_u_checkout_master where ch_state = 'Y' and (upload_success is null or upload_success != 'Y')) as pay where pay.payamount > 0;";
string sqlQueryNegetivePayamountFormat = "SELECT ch_payno, ch_billno, dt_operdate, payamount FROM (SELECT ch_payno, ch_billno, dt_operdate, (num_cost - num_discount) AS payamount FROM cybr_u_checkout_master) pay WHERE (ch_billno = '{0}') AND (ch_payno <> '{1}')";
string sqlInsertSuccess = "update cybr_u_checkout_master set upload_success = 'Y' where ch_payno in(";
SqlCommand queryPayAmountCmd = new SqlCommand(sqlQueryPayAmount, con);
con.Open();
con2.Open();
SqlDataReader dataReader = queryPayAmountCmd.ExecuteReader();
List<String> successPayNos = new List<String>();
while (dataReader.Read())
{
String payamount = dataReader["payamount"].ToString();
String sqlQueryNegetivePayamount = string.Format(sqlQueryNegetivePayamountFormat, dataReader["ch_billno"].ToString(), dataReader["ch_payno"].ToString());
SqlCommand queryNagetivePayAmountCmd = new SqlCommand(sqlQueryNegetivePayamount, con2);
SqlDataReader dataReader2 = queryNagetivePayAmountCmd.ExecuteReader();
if (dataReader2.Read())
{
string negativePayAmount = dataReader2["payamount"].ToString();
Decimal sub = Decimal.Parse(payamount) - Decimal.Parse(negativePayAmount);
payamount = sub.ToString();
}
dataReader2.Close();
salesUploadServices.postsalescreaterequest request = createpostsalescreate(dataReader["ch_payno"].ToString(), dataReader["payamount"].ToString(), dataReader["dt_operdate"].ToString());
salesUploadServices.postsalescreateresponse response = postsalescreate(request); 展开
String constr = ConfigurationManager.ConnectionStrings["connectIssrestv6"].ConnectionString.ToString();
SqlConnection con = new SqlConnection(constr);
SqlConnection con2 = new SqlConnection(constr);
string sqlQueryPayAmount = "select pay.ch_payno, pay.ch_billno, pay.dt_operdate, pay.payamount from( select ch_payno, ch_billno, dt_operdate, (num_cost - num_discount) as payamount from cybr_u_checkout_master where ch_state = 'Y' and (upload_success is null or upload_success != 'Y')) as pay where pay.payamount > 0;";
string sqlQueryNegetivePayamountFormat = "SELECT ch_payno, ch_billno, dt_operdate, payamount FROM (SELECT ch_payno, ch_billno, dt_operdate, (num_cost - num_discount) AS payamount FROM cybr_u_checkout_master) pay WHERE (ch_billno = '{0}') AND (ch_payno <> '{1}')";
string sqlInsertSuccess = "update cybr_u_checkout_master set upload_success = 'Y' where ch_payno in(";
SqlCommand queryPayAmountCmd = new SqlCommand(sqlQueryPayAmount, con);
con.Open();
con2.Open();
SqlDataReader dataReader = queryPayAmountCmd.ExecuteReader();
List<String> successPayNos = new List<String>();
while (dataReader.Read())
{
String payamount = dataReader["payamount"].ToString();
String sqlQueryNegetivePayamount = string.Format(sqlQueryNegetivePayamountFormat, dataReader["ch_billno"].ToString(), dataReader["ch_payno"].ToString());
SqlCommand queryNagetivePayAmountCmd = new SqlCommand(sqlQueryNegetivePayamount, con2);
SqlDataReader dataReader2 = queryNagetivePayAmountCmd.ExecuteReader();
if (dataReader2.Read())
{
string negativePayAmount = dataReader2["payamount"].ToString();
Decimal sub = Decimal.Parse(payamount) - Decimal.Parse(negativePayAmount);
payamount = sub.ToString();
}
dataReader2.Close();
salesUploadServices.postsalescreaterequest request = createpostsalescreate(dataReader["ch_payno"].ToString(), dataReader["payamount"].ToString(), dataReader["dt_operdate"].ToString());
salesUploadServices.postsalescreateresponse response = postsalescreate(request); 展开
1个回答
展开全部
建议将错误贴出
可能的情况是,1.某一列不充许空,而这个输入值为空,
2.xxtime的输入方式为,我只改第一二处,其余类推.
SQL = "insert into dbrc(no,bb1time,bb1no,bb2time,bb2no,bb3time,bb3no,bb4time,bb4no,bb5time,bb5no,bb6time,bb6no,rbtime,rbno) values ('" & Text1.Text & "',#" & lsq1.Text & "#,'" & lshm1.Text & "',#" & lsq2.Text & "#,'" & lshm2.Text & "','" & lsq3.Text & "','" & lshm3.Text & "','" & lsq4.Text & "','" & lshm4.Text & "','" & lsq5.Text & "','" & lshm5.Text & "','" & lsq6.Text & "','" & lshm6.Text & "','" & tsq.Text & "','" & hshm.Text & "')"
可能的情况是,1.某一列不充许空,而这个输入值为空,
2.xxtime的输入方式为,我只改第一二处,其余类推.
SQL = "insert into dbrc(no,bb1time,bb1no,bb2time,bb2no,bb3time,bb3no,bb4time,bb4no,bb5time,bb5no,bb6time,bb6no,rbtime,rbno) values ('" & Text1.Text & "',#" & lsq1.Text & "#,'" & lshm1.Text & "',#" & lsq2.Text & "#,'" & lshm2.Text & "','" & lsq3.Text & "','" & lshm3.Text & "','" & lsq4.Text & "','" & lshm4.Text & "','" & lsq5.Text & "','" & lshm5.Text & "','" & lsq6.Text & "','" & lshm6.Text & "','" & tsq.Text & "','" & hshm.Text & "')"
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询