I am trying to concatenate image url (string) with img tag but i am not sure how to put " after src=. Please help to concatenate this.
response.write("<img src=" & '"' & rs("ProductImage") & '"' &" /><br/>")
You concatenate strings by using the + operator. For string literals and string constants, concatenation occurs at compile time; no run-time concatenation occurs. For string variables, concatenation occurs only at run time.
Concat() or + is the best way.
PostgreSQL allows you to directly concatenate strings, columns and int values using || operator. Here is the SQL query to concatenate columns first_name and last_name using || operator. You can even concatenate string with int using || operator.
You have to double up the quotes:
Response.Write("<img src=""" & rs("ProductImage") & """ /><br/>")
Since HTML can use double quotes or single quotes, why not just use single quotes for the HTML. So your code would look like this:
response.write("<img src='" & rs("ProductImage") & "' /><br/>")
The resulting output would look like this:
<img src='ProductImageUrl' /><br/>
Another option is to use the chr function:
Response.Write("<img src=" & chr(34) & rs("ProductImage") & chr(34) & " /><br/>")
ascii code 34 is the double quote. We use this all the time when writing out HTML.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With