Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Why is string passed from Access VBA to SQL Server Stored Procedure losing the chr(13) from vbcrlf

Posted on 2008-06-10
4
436 Views
Last Modified: 2012-05-05
I have simple stored procedure to create a new customer record if one with a matching name and postcode does not automatically exist. The procedure is called from Microsoft Access using VBA. The address is a string with the lines seperated by vbcrlf.

When the procedure is called from Access the address ends up with lines seperated only by char(10). The char(13) part of the vbcrlf is lost somehow. If I test the procedure from SQL Server management studio it works fine.

Any ideas on how I can get the full newline control sequence into the database (I could add a few lines to insert a char(13) in front of any orphaned char(10) but that is not elegant!)
ALTER PROCEDURE [dbo].[CUSTOMERINSERT] @NAME VARCHAR(50),@ADDRESS VARCHAR(2000),@POSTCODE VARCHAR(50),@ID INT OUTPUT
AS
BEGIN
	SELECT @ID=ID FROM CUSTOMER WHERE [NAME]=@NAME AND POSTCODE=@POSTCODE
	IF @ID IS NULL
		BEGIN
			INSERT INTO CUSTOMER ([NAME],ADDRESS,POSTCODE) VALUES (@NAME,@ADDRESS,@POSTCODE)
			SET @ID=SCOPE_IDENTITY()
		END
	IF @ID IS NULL
		SET @ID=0
END

Open in new window

0
Comment
Question by:BOIT
  • 2
  • 2
4 Comments
 
LVL 7

Expert Comment

by:Chrisedebo
ID: 21752331
I believe that appearances can be deceptive.

when you use vbcrlf to concatenate strings, and then pass them to SQL via a stored procedure, I think it will just use SQL's new line character (char 10), this will however appear to be correct when testing the procdure in the management studio.

Try using the character codes when calling the stored proc

ie char(13) & char(10) &
instead of vbcrlf & 
0
 

Author Comment

by:BOIT
ID: 21757785
I tried concatenating the string using chr(13) & chr(10) instead of vbcrlf but it makes no difference.

I have just realised that I have made a mistake in outlining this question. The actual technology I am using for this bit of the project is a web service written in vb in asp.net. Therefore the stored procedure is being called from iis on the target host.

As this changes the title of the question and quite possibly the solution I am going to repost the question and request a close on this one.

Thank you for your comment Chrisedebo and I will welcome your input on the reposted question if possible.

0
 
LVL 7

Expert Comment

by:Chrisedebo
ID: 21758231
Sure, if you could post a link to it here then I can find it easier :o)
0
 

Accepted Solution

by:
BOIT earned 0 total points
ID: 21758339
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question