sql 语句在.net中的应用

来源:百度知道 编辑:UC知道 时间:2024/05/31 18:10:17
Public Sub updataBookInfo(ByVal fNo As String, ByVal fName As String, ByVal fPrice As Double)
cmd.CommandText = "updata BookInfo set BookName='" & fName & "',Price= & fPrice & , where BookNO='" & fNo & "'"
cmd.Connection.Open()
cmd.ExecuteReader()
cmd.Connection.Close()
End Sub
其中fPrice 是 Double,请问这个cmd.CommandText应若何来改! 谢谢

"updata BookInfo set BookName='" & fName & "',Price="& fPrice & " where BookNO='" & fNo & "'"

fPrice.toString() 即可作为字符串拼在commandText中了

申明一个string updateSql=string.format("update table set bookname='{0}',price={1} where bookno='{2}'",bname,bprice,bno);
cmd.commandText=updateSql;
这样不久解决了
可以不用拼接字符串,省去了很多麻烦