日期:2014-05-18  浏览次数:20560 次

请问这句SQL语句应该怎样写?
If   CheckBox1.Checked   =   "true "   Then  
Dim   mysql   As   String   =   "insert   into   pinfor   (pname,price,lprice,pkind,pimg,pmsg,tj)   values   ( ' "   +   textbox1.Text.Replace( " ' ",   " ").Replace( " < ",   " ")   +   " ', "   +   Str(Int(textbox3.Text))   +   ", "   +   Str(Int(textbox4.Text))   +   ", ' "   +   ptlist.SelectedValue   +   " ', ' "   +   pimg   +   " ', ' "   +   textbox7.Text.Replace( " ' ",   " ").Replace( " < ",   " ").Replace(Chr(10),   " <br> ")   +   " ', ' "   +   Str(1)   +   " ') "  
Else  
Dim   mysql   As   String   =   "insert   into   pinfor   (pname,price,lprice,pkind,pimg,pmsg,tj)   values   ( ' "   +   textbox1.Text.Replace( " ' ",   " ").Replace( " < ",   " ")   +   " ', "   +   Str(Int(textbox3.Text))   +   ", "   +   Str(Int(textbox4.Text))   +   ", ' "   +   ptlist.SelectedValue   +   " ', ' "   +   pimg   +   " ', ' "   +   textbox7.Text.Replace( " ' ",   " ").Replace( " < ",   " ").Replace(Chr(10),   " <br> ")   +   " ', ' "   +   Str(0)   +   " ') "  


checkbox1是为了判断这片文章是否是推荐文章,如果是true,   最后一个tj字段赋值为1,不是则赋值为0,我这样写反正不对,高手帮我看看,应该怎样去做啊?


------解决方案--------------------
Dim mysql As String = "insert into pinfor (pname,price,lprice,pkind,pimg,pmsg,tj) values ( ' " + textbox1.Text.Replace( " ' ", " ").Replace( " < ", " ") + " ', " + Str(Int(textbox3.Text)) + ", " + Str(Int(textbox4.Text)) + ", ' " + ptlist.SelectedValue + " ', ' " + pimg + " ', ' " + textbox7.Text.Replace( " ' ", " ").Replace( " < ", " ").Replace(Chr(10), " <br> ") + " ', ' " + Str( CheckBox1.Checked ? 1 : 0 ) + " ') "
------解决方案--------------------
代码太长晕啊
C#语法 string strChecked = CheckBox1.Checked ? 1 : 0
VB语法 Dim strChecked As String
strChecked = IIf(CheckBox1.Checked, 1, 0).ToString()