 |
| SQL Server ASP Discussions about ASP programming with Microsoft's SQL Server. For more ASP forums, see the ASP forum category. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the SQL Server ASP section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

November 9th, 2004, 08:36 PM
|
|
Registered User
|
|
Join Date: Nov 2004
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
stored procedures and sqloledb
I am trying to upgrade my application db connection type from odbc to sqloledb provider using asp. Most of my stored procedures work except for some parameterized stored procedures which take datetime and/or integer as parameters.
The error in my web app is:
Microsoft OLE DB Provider for SQL Server error 80040e57
String or binary data would be truncated.
I checked the obvious...datatypes matching...
I am using MS SQL 2000 SP 3a on Windows 2000. I get the error on IIS IV (NT) and IIS 6 (win2003) and I get the same error using Call, Exec and Adodb command methods.
The values of the datatypes are valid in my test cases. I have made some progress changing the datetime parameters to string parameters, packing the string as yyyy-mm-dd but that seems excessive and I am wondering what could be wrong.
Thanks in advance for any suggestions.
|
|

November 10th, 2004, 01:25 AM
|
|
Friend of Wrox
|
|
Join Date: Oct 2003
Posts: 463
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Generally such an error happens when the data you are trying to insert is larger than what the destination field can contain. For example, the value passed may be a long integer when the destination field is of type integer.
I need to know more details to say something specific about this problem. Could you please post the code of stored procedure and the code which calls it ?
|
|

November 10th, 2004, 08:03 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
|
|
Yes Terre,
It would be better to post some the code from SP and how that is called in your ASP pages. That should help us find what you are missing.
Cheers!
_________________________
- Vijay G
Strive for Perfection
|
|

November 10th, 2004, 03:26 PM
|
|
Registered User
|
|
Join Date: Nov 2004
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Thanks for the interest. I have run this sp for years using odbc. Enclosed you will see all three methods (call, exec, adodb command) and they all return the same error.
I have run this code on a variety of webservers and have checked the mdac on each...same error. When a collegue runs this code on one of those webservers, pointing to a different database server, the code executes with no problem.
It seems like this might be some picky db config issue.
Thanks for all the help.
-Terre
Here is the sp:
CREATE PROCEDURE up_exp_date @client_id int, @exp_date datetime
AS
UPDATE client SET exp_date = @exp_date
WHERE client_id = @client_id
Here is the vbscript:
dbLetterDev = "Provider=SQLOLEDB;Data Source=122.xx.xxx.xxx;database=letter;uid=xx;pwd=x x;"
cnn.Open dbLetterDev
if Request.Form( "submit" ) = "use EXEC" then
exp_date = Request.Form("exp_date")
strSQL="EXEC up_exp_date client_id=1688,exp_date='"&exp_date&"'"
'I have also tested :
' strSQL="EXEC up_exp_date '@client_id=1688,@exp_date='"&exp_date&"'"
err.clear
cnn.Execute strSQL
if err <> 0 then
Response.Write("System Error:<br />")
Response.Write("Error Number="&Err.Number&"<br />")
Response.Write("Error Source="&Err.Source&"<br />")
Response.Write("Error Desc="&Err.Description&"<br />")
Response.Write("System Error:<br />")
end if
end if
if Request.Form( "submit" ) = "use Call" then
exp_date = Request.Form("exp_date")
if isDate(exp_date) then
strSQL="{Call up_exp_date (1688,'"&exp_date&"')}"
err.clear
cnn.Execute strSQL
if err <> 0 then
Response.Write("System Error:<br />")
Response.Write("Error Number="&Err.Number&"<br />")
Response.Write("Error Source="&Err.Source&"<br />")
Response.Write("Error Desc="&Err.Description&"<br />")
Response.Write("System Error:<br />")
end if
else
strError = strError&"not a date"
end if
end if
if Request.Form( "submit" ) = "use ADODB COMMAND" then
Dim prm1
Dim prm2
Dim cmd
set cmd = Server.CreateObject("ADODB.Command")
cmd.ActiveConnection = cnn
cmd.CommandType = 4
cmd.CommandText = "up_exp_date"
Set prm1 = cmd.CreateParameter("client_id", adInteger, adParamInput)
cmd.Parameters.Append prm1
Set prm2 = cmd.CreateParameter("exp_date", adDate, adParamInput)
cmd.Parameters.Append prm2
prm1.Value = 1688
prm2.Value=Request.Form("exp_date")
err.clear
on error resume next
cmd.Execute
if err <> 0 then
Response.Write("System Error:<br />")
Response.Write("Error Number="&Err.Number&"<br />")
Response.Write("Error Source="&Err.Source&"<br />")
Response.Write("Error Desc="&Err.Description&"<br />")
Response.Write("System Error:<br />")
end if
end if
|
|

November 11th, 2004, 03:47 AM
|
|
Friend of Wrox
|
|
Join Date: Oct 2003
Posts: 463
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Hello Terre,
What is the format of exp_date ? Could you please make it as yyyy-mm-dd and have a try ?
If that create any problem, you may execute the following statement before your SP.
cnn.Execute "SET DATEFORMAT ymd"
This should solve the problem.
|
|

November 12th, 2004, 11:27 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
|
|
Yes, it should be good to pass that date value to the procedure in yyyy-mm-dd format. That should be what you were missing.
Else post here on what errors you face then.
Cheers!
_________________________
- Vijay G
Strive for Perfection
|
|

November 12th, 2004, 01:20 PM
|
|
Registered User
|
|
Join Date: Nov 2004
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Ok I did all of that. Same error -- "String or binary data would be truncated. "
If I re-write my stored procedure to take char(10) instead of datetime and if I do the type conversion from string to datetime in the stored procedure, I can make this work. This just seems wrong to me. Can't sqloledb provider and ms sql agree on datatypes? Other developers tell me they have run this code on a different sql server and get no error.
|
|

November 15th, 2004, 01:53 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
|
|
Can you post on what comes along with "exp_date" variable?
Code:
Response.write Request.Form("exp_date")
Cheers!
_________________________
- Vijay G
Strive for Perfection
|
|

November 15th, 2004, 01:20 PM
|
|
Registered User
|
|
Join Date: Nov 2004
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
If I type 2007-01-01 into the form, 2007-01-01 comes back on the response.write request.form("exp_date"). If I type 2009-2-15, 2008-2-15 comes back. If I type 2004-1-12 00:00:00, then 2004-1-12 00:00:00 comes back. All these values return a string or binary data would be truncated error. If I type "george" into the form as the expiration date, I get Error converting data type varchar to datetime which tells me it knows something about that target datatype.
I don't think there is anything being added by asp. I think this is an issue with the oledb provider and the sql server.
Thanks for the help. I'm still stumped
|
|

November 16th, 2004, 03:08 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
|
|
Now the next step would be to try this from sql query analyser.
EXEC up_exp_date @client_id=1688,@exp_date='<DATE_VALUE>'
See if that works fine.
Looks like you are missing the @ prefix in the following ASP code. I suspect that should be causing the error.
strSQL="EXEC up_exp_date client_id=1688,exp_date='"&exp_date&"'"
Hope that helps.
Cheers!
_________________________
- Vijay G
Strive for Perfection
|
Similar Threads
|
| Thread |
Thread Starter |
Forum |
Replies |
Last Post |
| Stored Procedures |
KeviJay |
VB Databases Basics |
1 |
June 5th, 2008 07:17 AM |
| Stored Procedures |
itHighway |
SQL Server 2000 |
3 |
November 23rd, 2005 10:08 AM |
| Stored Procedures |
jazzcatone |
Classic ASP Databases |
0 |
August 28th, 2005 02:57 PM |
| Stored Procedures |
stu9820 |
ASP.NET 1.x and 2.0 Application Design |
2 |
January 15th, 2005 04:09 AM |
| Stored Procedures |
stu9820 |
Access |
3 |
February 8th, 2004 01:13 PM |
|
 |