Solved

Can't enter data into SQL table

Posted on 2008-10-24
7
645 Views
Last Modified: 2012-05-05
I am learning C# Express and SQL Express. I created a table following the directions in the book I am using (Head First C#, page 28). I created a table and tried to enter data into the first row. But when I finish entering the data, I get this error message:

No row was updated.
The data in row 1 was not committed.
Error Source: .Net SqlClient Data Provider.
Error Message: String or binary data would be truncated.
The statement has been terminated.
Correct the erros and retury or press ESC to cancel the change(s).

I would appreciate help with this! Here I am, anxious to learn C#, and I am stuck at this early stage! Many thanks.

0
Comment
Question by:JohannSebastian
  • 3
  • 3
7 Comments
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 22797060
the problem is that your table has (at least) 1 column, for which the size is smaller than the data you want to save to.

like employee_name being varchar(20), and you try to save 'Mr Jesus Da Cruz Bernado Alberto' into that.

please cross check.
0
 

Author Comment

by:JohannSebastian
ID: 22797204
Dear angellll,

My table is like this:

Contact ID (key)       int                      no nulls
Name                       nvchar(50)        nulll ok
Company                 nvchar(50          null ok
Telephone               nvchar(50          null ok
Email                        nvchar(50          null ok
Client                       bit (boolean)       null ok
Last Call                 datetime               null ok

The fields I entered were:
Contact ID: (I entered nothing because it is auto generated.)
Name           Lloyd Jones
Company      Black Box Inc.
Telephone    (718)555-5638
Email             LJones@blackboxinc.com
Client            True
Last Call       5/26/07 (SQL changes this to 5/26/07 12:00:00 AM as soon as I press Return)

It seems to me I have not exceeded the length or size limit of any of these fields. (???)
0
 
LVL 142

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 22797235
please show the relevant code, or are you entering the data directly in sql server?
0
VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

 

Author Comment

by:JohannSebastian
ID: 22797424
There is no code. I am entering the data directly (typing it in, in the fields of the first row.)

I am attaching a screen shot.


SQLerror.jpg
0
 

Author Comment

by:JohannSebastian
ID: 22797661
I erased the value in the Email field, and the row got accepted!

But I need to enter values in the email fields. Why was LJones@blackboxinc.com not accepted?
0
 
LVL 15

Expert Comment

by:jorge_toriz
ID: 22798008
You email field could be 255 chars length... is the standard
0
 
LVL 142

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 250 total points
ID: 22798199
type 1 for the bit field, and not "true/false"

otherwise, is there a trigger on the table?
0

Featured Post

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

809 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