Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Can't enter data into SQL table

Posted on 2008-10-24
7
Medium Priority
?
661 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
7 Comments
 
LVL 143

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 143

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
Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

 

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 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 750 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

Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

Question has a verified solution.

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

In the first part of this tutorial we will cover the prerequisites for installing SQL Server vNext on Linux.
A Stored Procedure in Microsoft SQL Server is a powerful feature that it can be used to execute the Data Manipulation Language (DML) or Data Definition Language (DDL). Depending on business requirements, a single Stored Procedure can return differe…
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
Via a live example, show how to shrink a transaction log file down to a reasonable size.

670 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