开发者

Insert string with comma into varchar?

开发者 https://www.devze.com 2023-03-27 06:35 出处:网络
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

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()
0

精彩评论

暂无评论...
验证码 换一张
取 消