using(sqlCommand cmd=conn.CreateCommand()) //用using管理sqlcommand,用连接字符串conn建立一个sqlcommand
{
cmd.CommandText="select *from T_Users where username=@username"; //sqlcommand语句的内容为查询T_Users 表中username为@username参数的值
cmd.parameters.Add(new sqlparameter("username",txtusername.Text)); //把txtusername的文本赋值给username参数
}
cmd.parameters.Add(new sqlparameter("username",txtusername.Text)); |