Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations GregLocock on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Specifying carriage return/line feed in an SQL statement

Status
Not open for further replies.

Guest
Hi there, I hope you can help us.

We're using this statement to import some values into a database:
SQLStatement = "INSERT MyTable (ID, VALUE) VALUES ('" & IDString & "', '" & VALUEString & "')"

The problem is that the strings might contain carriage returns/line feeds, i.e.
VALUEString = "Line 1." & vbCrLf & "Line 2."

It only imports up until the first vbCrLf. We have tried replacing vbCrLf with "\n", but this doesn't work either. What is the correct format for inserting a value that contains new line characters?

Thanks for your time,
Lasse.
 
Replies continue below

Recommended for you

Dear SpaceRain,

I have worked in simial problem. Change your column type to VarChar and instead of single quote (') in insert into statement use double quotes. I have attached a example for your convience.

INSERT INTO mytab (ID, VAL) VALUES (" & CHR(34) & idstr & CHR(34) & "," & CHR(34) & valstr & CHR(34) & ")"

For further details please let me know things like a complete description like database environment, column types etc.
 
Hi,

i would like to insert a carriage return into my select statement - but I couldn't find the sign for the carriage return anywhere!

I hope there is help out there,

Ramona
 
Hi,

i would like to insert a carriage return into my select statement - but I couldn't find the sign for the carriage return anywhere!

I hope there is help out there,

Ramona
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor