问题描述
我想在标签中出现一个在sql bd中的增量字段,我想拥有下一个#。
ex:在我的bd中我完成了AA002我想要显示在AA003标签中。
我尝试过:
SqlConnection sc = new SqlConnection(Data Source = 7KH9R22 \\SQLEXPRESS; Integrated Security = TRUE; Initial Catalog = RSE);
//添加+1时没有出现但是当我删除+时1显示当前最后一个#bd
SqlCommand cmd = new SqlCommand(SELECT MAX(CLIENTno)+1 FROM FROM CLIENT,sc);
cmd.CommandType = CommandType.Text;
cmd.Connection.Open();
object o = cmd.ExecuteScalar();
if(o!= DBNull.Value)label16.Text = o.ToString();
sc.Close( );
I want to make appear in a label an incremential field that is in a sql bd, I want to have the next #.
ex: in my bd I am done to AA002 I want to show in the label AA003.
What I have tried:
SqlConnection sc =new SqlConnection("Data Source=7KH9R22\\SQLEXPRESS;Integrated Security=TRUE;Initial Catalog=RSE");
//nothing appear when add +1 but when i remove +1 is show the current last # in bd
SqlCommand cmd = new SqlCommand("SELECT MAX (CLIENTno)+1 FROM CLIENT ", sc);
cmd.CommandType = CommandType.Text;
cmd.Connection.Open();
object o = cmd.ExecuteScalar();
if (o != DBNull.Value) label16.Text = o.ToString();
sc.Close();
推荐答案
这篇关于C#SQL如何在标签中显示bd的增量数字,当是字母数字时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!