Solved

Can't enter data into SQL table

Posted on 2008-10-24
7
638 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]
Comment Utility
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
Comment Utility
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]
Comment Utility
please show the relevant code, or are you entering the data directly in sql server?
0
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 

Author Comment

by:JohannSebastian
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
type 1 for the bit field, and not "true/false"

otherwise, is there a trigger on the table?
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

In this article I will describe the Backup & Restore method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed
Via a live example, show how to shrink a transaction log file down to a reasonable size.

762 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now