JohannSebastian
asked on
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.
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.
ASKER
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. (???)
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. (???)
please show the relevant code, or are you entering the data directly in sql server?
ASKER
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
I am attaching a screen shot.
SQLerror.jpg
ASKER
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?
But I need to enter values in the email fields. Why was LJones@blackboxinc.com not accepted?
You email field could be 255 chars length... is the standard
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
like employee_name being varchar(20), and you try to save 'Mr Jesus Da Cruz Bernado Alberto' into that.
please cross check.