想生成类似20090409001的序号。
string sUsername = "";
string date = DateTime.Now.ToString("yyyyMMdd");
DataTable dtmax = Conn.query("select sUserName from xUser where sUserName like '" + date + "%' order by sUserName desc ");
if (dtmax.Rows.Count == 0) sUsername = date + "001";
else sUsername =date +String .Format ("{0:D3}", (Convert.ToInt32(dtmax.Rows[0]["sUserName"].ToString().Substring(7)) + 1));
txtsUserName.Text = sUsername;
本文转自 陈敬(Cathy) 博客园博客,原文链接:http://www.cnblogs.com/janes/archive/2009/04/10/1433099.html,如需转载请自行联系原作者