Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Passing data to a stored procedure

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2003-03-31 : 07:21:16
Jaime Escobar writes "I'm trying to pass data from an asp page to a stored procedure. If I pass a number (no spaces) it works but as soon as I try to pass a date(mm/dd/yyyy) or a name (first and last name) it stops and gives me an error (see below)

here is the error when I use a name:

Error Type:
Microsoft OLE DB Provider for SQL Server (0x80040E14)
Line 1: Incorrect syntax near 'Escobar'.

error when I use a date:

Error Type:
Microsoft OLE DB Provider for SQL Server (0x80040E14)
Line 1: Incorrect syntax near '/'.

It looks like in the name it stops at the space between the first and last name, and in the date it stops on the '/'

What am I doing wrong?

The solution to this problem is probably very easy but I am completly out of ideas. I hope you guys have a solution for me.

Jaime Escobar"

Bambola
Posting Yak Master

103 Posts

Posted - 2003-03-31 : 07:42:48
Use ISO format yyyy-mm-dd for dates.

Replace quotes in strings: replace(first_name,"'","''")

Bambola.



Go to Top of Page

SqlStar
Posting Yak Master

121 Posts

Posted - 2003-03-31 : 10:21:35
Hi,

I think its not the correct answer. If u want to send date value as "dd/mm/yyyy", ur procedure's insert statement should be use with "Convert" function.
Ex:
convert(datetime,'31/12/2001', 103)

Send me ur paramter values and SP code.





":-) IT Knowledge is power :-)"
Go to Top of Page

Bambola
Posting Yak Master

103 Posts

Posted - 2003-03-31 : 11:50:24
quote:

I think its not the correct answer. If u want to send date value as "dd/mm/yyyy", ur procedure's insert statement should be use with "Convert" function.
Ex:
convert(datetime,'31/12/2001', 103)



SqlStar - your approach depends on the server settings. while with yyyy-mm-dd you can never go wrong. Try it and see for yourself.

declare @d datetime
select @d = '31/03/2003'
select @d = '03/31/2003'
select @d = '2003-03-31'

One of the first 2 will result an error. the last one won't.

Bambola.


Edited by - bambola on 03/31/2003 11:52:09
Go to Top of Page
   

- Advertisement -