string .format

简介:

想生成类似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,如需转载请自行联系原作者

相关文章
|
10月前
|
SQL 数据库
【YashanDB 知识库】导入数据时报错:YAS-00008 type convert error:literal does not match format string
【YashanDB 知识库】导入数据时报错:YAS-00008 type convert error:literal does not match format string
|
10月前
|
SQL 数据库
【YashanDB知识库】导入数据时报错:YAS-00008 type convert error:literal does not match format string
【YashanDB知识库】导入数据时报错:YAS-00008 type convert error:literal does not match format string
|
安全
格式化字符串漏洞(Format String Attack)
格式化字符串漏洞(Format String Attack)
330 0
|
索引 Python
技巧 | 5000字超全解析Python三种格式化输出方式【% / format / f-string】
技巧 | 5000字超全解析Python三种格式化输出方式【% / format / f-string】
解决Format string is not a string literal (potentially insecure)问题
在用宏实现部分字符串格式化问题时,stringWithFormat方法会出现【Format string is not a string literal (potentially insecure)】警告
785 0
Python爬取中国最好大学排行榜报错TypeError: unsupported format string passed to NoneType.__format__
Python爬取中国最好大学排行榜报错TypeError: unsupported format string passed to NoneType.__format__
|
Python
Python格式字符串的三种方法你都掌握了吗,%s%d%f+format()+f-string,深度测评YYDS实至名归
Python格式字符串的三种方法你都掌握了吗,%s%d%f+format()+f-string,深度测评YYDS实至名归
310 0
Python格式字符串的三种方法你都掌握了吗,%s%d%f+format()+f-string,深度测评YYDS实至名归
ORA-01861: literal does not match format string
在创建基线过程中遇到了这个错误:SYS@db1> BEGIN2  DBMS_WORKLOAD_REPOSITORY.CREATE_BASELINE (3    start_time  =>'2017-03-06 7:00:00' ,4    end_time   =>...
2622 0