SQL + Dreamweaver

  • Thread starter Thread starter Dam6
  • Start date Start date
D

Dam6

Hello,

I seem to be running into a problem with regards to data size etc:

Explanation:
A person opens a .aspx page and posts and writes an article of a few
thousand words. When they click Insert Record they get this message:
System.Data.SqlClient.SqlException: String or binary data would be
truncated.
The statement has been terminated.
at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior
cmdBehavior, RunBehavior runBehavior, Boolean returnStream)
at System.Data.SqlClient.SqlCommand.ExecuteNonQuery()
at DreamweaverCtrls.DataSet.DoInit()

Problem:
It's to do with the size of the data being inserted into the record and I
have increased the VarChar length to 6000 characters to compensate. Is there
a better DataType to hold the information? With MS Access this is a major
problem but I would expect that but not with SQL Server? Any suggestions?
 
SQL Server allows 8k per data page. If you have an int column (4 bytes), you
still have almost 8,000 ansi characters to work with. This is not enough for
the verbose, however, which forces you to use a Text field:

CREATE TABLE ArticlesForTheReallyVerbose
(
ArticleID int IDENTITY(1,1) PRIMARY KEY
, ArticleText text NOT NULL
)

You might think you can separate out the text into multiple fields, ala:

CREATE TABLE ArticlesForTheReallyVerbose
(
ArticleID int IDENTITY(1,1) PRIMARY KEY
, ArticleText1 varchar (7000) NOT NULL
, ArticleText2 varchar (7000) NOT NULL
)

.... but you will go over the page size if someone actually is verbose.

There are pitfalls with text fields, but this case calls for one.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

***************************
Think Outside the Box!
***************************
 
Thanks!!!

Cowboy (Gregory A. Beamer) - MVP said:
SQL Server allows 8k per data page. If you have an int column (4 bytes),
you
still have almost 8,000 ansi characters to work with. This is not enough
for
the verbose, however, which forces you to use a Text field:

CREATE TABLE ArticlesForTheReallyVerbose
(
ArticleID int IDENTITY(1,1) PRIMARY KEY
, ArticleText text NOT NULL
)

You might think you can separate out the text into multiple fields, ala:

CREATE TABLE ArticlesForTheReallyVerbose
(
ArticleID int IDENTITY(1,1) PRIMARY KEY
, ArticleText1 varchar (7000) NOT NULL
, ArticleText2 varchar (7000) NOT NULL
)

... but you will go over the page size if someone actually is verbose.

There are pitfalls with text fields, but this case calls for one.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

***************************
Think Outside the Box!
***************************
 
Back
Top