这里的账单号码在10点后没有增加。请帮忙!!紧急! [英] Here bill number does not increment after 10. Please help!! Urgent!
本文介绍了这里的账单号码在10点后没有增加。请帮忙!!紧急!的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
private void cashreciept_Load(object sender, EventArgs e)
{
SqlDataAdapter da = new SqlDataAdapter("SELECT TOP 1 [Bill No] FROM cashreceipt ORDER BY [Bill No] DESC", sq.connection());
DataTable dt1 = new DataTable();
da.Fill(dt1);
if (dt1.Rows.Count > 0)
{
billno = Convert.ToInt32(dt1.Rows[0][0]);
billno +=1;
txtbill.Text = billno.ToString();
}
else
{
string h = "1/1/1911";
string c = "insert into cashreceipt values('" + 0 + "','" + 0 + "','" + 0 + "','" + 0 + "','" + 0 + "','" + 0 + "','" + h + "')";
SqlCommand ccmd = new SqlCommand(c, sq.connection());
ccmd.ExecuteNonQuery();
SqlDataAdapter da1 = new SqlDataAdapter("SELECT TOP 1 [Bill No] FROM cashreceipt ORDER BY [Bill No] DESC", sq.connection());
DataTable dt2 = new DataTable();
da1.Fill(dt2);
if (dt2.Rows.Count > 0)
{
billno = Convert.ToInt32(dt2.Rows[0][0]);
billno = billno+1;
txtbill.Text = billno.ToString();
}
}
}
推荐答案
为什么?可能是因为您将账单号码存储为字符串而非数字值。
因此,当存储并返回最高值时,9值优先于10返回
就文本而言,降序值:
Why? Probably, because you are storing your bill number as a string, not a numeric value.
So when it gets stored and the top value returned, the "9" value is return in preference to the "10"
Descending values as far as text is concerned:
9
8
7
6
5
4
3
2
11
10
1
这篇关于这里的账单号码在10点后没有增加。请帮忙!!紧急!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文