Wrox Programmer Forums
|
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Basics 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
 
Old June 4th, 2004, 02:26 PM
Authorized User
 
Join Date: Jun 2004
Posts: 32
Thanks: 0
Thanked 0 Times in 0 Posts
Default String or binary data would be truncated.

I've got another problem with my newly upgraded SQL database from Access. When I tried to insert a large record, I got this error:
String or binary data would be truncated.
So I consulted some documentation and changed the data length of that record(varchar) from 50 to 8000(maximal). I could indeed insert that record now. However, my asp application could only retrieve a small part of that record. I checked my SQL server, and the record was there.

Again it was working fine with ACCESS before.

Any Idea? Thank you!

 
Old June 4th, 2004, 02:52 PM
Friend of Wrox
 
Join Date: Jan 2004
Posts: 303
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Have you tried SQL Server datatype "text"?
Also, post some code..if you can
 
Old June 4th, 2004, 03:13 PM
Authorized User
 
Join Date: Jun 2004
Posts: 32
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks for replying! I did want to try text, but with text, I couldn't change the default data length. You know what? After reading your posting, I thought I'd give it a shot anyway, and text worked!

I just don't understand how come data length 16 for text could solve the problem! I did read the documentation for data type text.

Thanks again for your help!I love this forum!

Cinderella

 
Old June 5th, 2004, 04:36 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

Hi Cindrella,

You can never change the length of a TEXT data type. It is fixed and chosen for usage only when you store huge content into a column.

text - Variable-length data with a maximum length of 2^31 - 1 characters

Also when you have decided to use text datatype, be sure that you use that COLUMN at last in all your sql statements. If you use them in between in your sql queries, it may vanish and you got to search that, wondering where it went.

Should use this way
Code:
Select SomeCol1, SomeCol2, SomeCol3, TextCol1, TextCol2 from tablename
Dont use this way
Code:
Select * from tablename
(Comment - Text columns could be the 2nd, 4th columns in your table)
OR
Code:
Select SomeCol2, TextCol1, TextCol2, SomeCol1, SomeCol3 from Tabelname
Just take a look at this page to know about SQL server datatypes, Choosing SQL Server 2000 Data Types

I assume you would have got this error String or binary data would be truncated when using varchar(8000) datatype. That is because one row can be of size 8060 at the maximum. I have already posted similar reply here. You may want to take a look at it.

Hope that explains.
Cheers!

_________________________
-Vijay G
Strive for Perfection





Similar Threads
Thread Thread Starter Forum Replies Last Post
String or binary data would be truncated spiffyaldo2 ASP.NET 1.0 and 1.1 Basics 1 March 21st, 2006 08:49 AM
Data truncated error message - why? wawdbd Visual C++ 0 April 22nd, 2004 03:52 AM
String getting truncated while displaying in asp anupamda Classic ASP Databases 2 February 10th, 2004 12:08 PM
String to Binary, Binary to String matt.fields VB.NET 2002/2003 Basics 3 November 5th, 2003 05:02 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.