SqlCommand cmd2 = new SqlCommand("select au_lname from authors where au_id='"+textBox1.Text.Trim()+"'", cn);------------------------------------------------------------------------------------------
其中这句au_id='"+textBox1.Text.Trim()+"'" 什么意思 为什么要加单引号、双引号、加号?哪位知道的,麻烦解释下, 刚学.net不久,提的问题还很基础,还忘高手海涵,不吝指点啊! 感激不尽了!!!
其中这句au_id='"+textBox1.Text.Trim()+"'" 什么意思 为什么要加单引号、双引号、加号?哪位知道的,麻烦解释下, 刚学.net不久,提的问题还很基础,还忘高手海涵,不吝指点啊! 感激不尽了!!!
"select au_lname from authors where au_id='aaa'"2个单引号包含一些字符代表SQL 里的一个字符串
2个双引号包含一些字符代表c#里的一个字符串
+代表链接字符串
这个只是把一个文本框的的值传递给数据库
比如 String cmd="aa";
select au_lname from authors where au_id=cmd;没区别 你看下吧
SqlCommand cmd2 = new SqlCommand("select au_lname from authors where au_id='"+textBox1.Text.Trim()+"'", cn);
"select au_lname from authors where au_id=[color=#3366FF]'"[/color]+textBox1.Text.Trim()+"[color=#3366FF]'"[/color]
"select au_lname from authors where au_id='"+"textBox1.Text.Trim()+"'"