• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 670
  • Last Modified:

Can't enter data into SQL table

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
JohannSebastian
Asked:
JohannSebastian
  • 3
  • 3
1 Solution
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
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
 
JohannSebastianAuthor Commented:
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
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
please show the relevant code, or are you entering the data directly in sql server?
0
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
JohannSebastianAuthor Commented:
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
 
JohannSebastianAuthor Commented:
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
 
jorge_torizResearch & Development ManagerCommented:
You email field could be 255 chars length... is the standard
0
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
type 1 for the bit field, and not "true/false"

otherwise, is there a trigger on the table?
0

Featured Post

[Webinar] Kill tickets & tabs using PowerShell

Are you tired of cycling through the same browser tabs everyday to close the same repetitive tickets? In this webinar JumpCloud will show how you can leverage RESTful APIs to build your own PowerShell modules to kill tickets & tabs using the PowerShell command Invoke-RestMethod.

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now