Nazarite

导航

2010年1月22日 #

C#与SQL命令中单引号字符串的不同效果

摘要: C#中执行含单引号字符串的SQL命令SQL命令:string selectCmd="select * from score where name='"+textBox1.Text+"'";当在 textBox1中直接输入含单引号的字符串查询会报异常.原因:SQL会将单引号括住的数据视为字符串,而双引号括住的数据,则被C#.NET视为字符串处理如:string selectCmd="select *... 阅读全文

posted @ 2010-01-22 18:32 Nazarite 阅读(1732) 评论(0) 推荐(1) 编辑

c# 获取字符串中的数字

摘要: c# 获取字符串中的数字 /// /// 获取字符串中的数字 /// /// 字符串 /// 数字 例子1:public static decimal GetNumber(string str) { decimal result = 0; if (str != null && str != string.Empty) { // 正则表达式剔除非数字字符(不包含小数点.) s... 阅读全文

posted @ 2010-01-22 14:16 Nazarite 阅读(6910) 评论(0) 推荐(0) 编辑