I'm trying to insert a string that contains a comma into a varchar in vb.net. How do I make the insert statement I'm开发者_StackOverflow building understand that I want "X,Y" to be in the varchar and not X in the varchar and Y in the next column?
Use parametised queries:
Dim cmd as new sqlcommand("INSERT INTO TableA (ColA) VALUES (@ColA)", Conn)
cmd.parameters.add("@ColA",sqldbtype.nvarchar).value = "X,Y"
cmd.executenonquery()
精彩评论