新增数据时遇到特殊字符
insert update数据时,遇到特殊字符会报错,可以用Parameters进行处理!
Dim com As SqlCommand
Dim sql As String
sql = "update " + tableName + " set ItemCName=@ItemCName,ItemEName=@ItemEName,ItemSName=@ItemSName,CreateDate=@creatTime where sn=1"
com = New SqlCommand(sql, conn)
com.Parameters.Add("@ItemCName", SqlDbType.NVarChar).Value = news
com.Parameters.Add("@ItemEName", SqlDbType.NVarChar).Value = news
com.Parameters.Add("@ItemSName", SqlDbType.NVarChar).Value = news
com.Parameters.Add("@creatTime", SqlDbType.DateTime).Value = createTime
conn.Open()
com.ExecuteNonQuery()
conn.Close()