摘要:
-- charindex 查找第一个参数在第二个参数中的位置 第三个参数起始位置--下标是从1开始的 返回0证明没有找到--里面的参数可以由表的字段来直接代替SELECT CHARINDEX('My','My abc Course',1 )select sname,charindex('张',sname,1) as '张出现的位置' from Student--Len 求字符长度select len('aaa')--求每个人的名字长度select sname,len(sname) as '姓名长度' 阅读全文
摘要:
--把一个表(或结果集)一次插入到数据库表中insert into class(cname,cDescription)select '01-2','01-21' union allselect '01-3','01-22' union allselect '01-4','01-23' union allselect '01-5','01-24' union allselect '01-6','01-25' union allselect 阅读全文
摘要:
当我们向有自动增涨列的表中添加完数据后,想得到刚刚生成的自动增涨列的值,有两种方法:第一种方法:\cmd.CommandText =“insert into class(cName,cDescription) output inserted.Id values(‘高三一班’,‘描述’)”;第二种方法在sql语句后加上; select @@identity: 阅读全文
摘要:
//在控件的KeyPress事件中private void txtPhoneNo_KeyPress(object sender, KeyPressEventArgs e) { char result=e.KeyChar; if (char.IsDigit(result)||result==8) { e.Handled = false; } else { e.Handled = true; } } 阅读全文
摘要:
DataTable dt = new DataTable();//创建一个DataTable的实例;//写一个简单的SqlHelper public static class SqlHelper { static string strCon = System.Configuration.ConfigurationManager.ConnectionStrings["strConn"].ConnectionString; /// <summary> /// 执行增加、修改、删除操作; /// </summary> /// <param name= 阅读全文