Alex Rivera | Logout

Escaping quotes in a string in VB6

Asked 2009-07-09T10:44:51.527
19

I am trying to make some small changes to an old VB web app I need to add quotes inside of a string I've had no luck so far. The string is

Dim sql As String = "Select * from  Usertask Where UserId = " & Session("UserId") & " and JobID=" & ddlReqTask.SelectedValue

I need to add quotes around the Session("UserID") value.

vb6
Edit
Report

1 Answer

12

To escape a quote you just need to add another quote, I believe this is what you need:

Dim sql As String = "Select * from  Usertask Where UserId = """ & Session("UserId") & """ and JobID=" & ddlReqTask.SelectedValue
answered 2009-07-09T10:48:01.393

Your Answer