The field is too small to accept the amount of data you attempted to add (1 Viewer)

alicengoc

New member
Local time
Tomorrow, 02:33
Joined
Feb 10, 2011
Messages
1
Hi I'm writing this code in order to save datas from my form to my access database. Here is the code

Code:
[SIZE=2][COLOR=#2b91af][SIZE=2][COLOR=#2b91af]
OleDbConnection[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] connection;
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]string[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] connectionString = [/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\\PATS\\PATS.mdb"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2];
[/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]string[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] commandString = [/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"INSERT INTO RegisteredUserParticulars (WindowsUserName, FullName, AdminNumber, ProjectYear, ProjectPath, SupervisorName, ProjectStartDate, ProjectEndDate)VALUES(?, ?, ?, ?, ?, ?, ?, ?)"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2];
connection = [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]new[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#2b91af][SIZE=2][COLOR=#2b91af]OleDbConnection[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2](connectionString);
[/SIZE][SIZE=2][COLOR=#2b91af][SIZE=2][COLOR=#2b91af]OleDbCommand[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] command = [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]new[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#2b91af][SIZE=2][COLOR=#2b91af]OleDbCommand[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2](commandString, connection);
connection.Open();
command.Parameters.AddWithValue([/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"?"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2], lbl1Trial3.Text);
command.Parameters.AddWithValue([/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"?"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2], lbl2Trial3.Text);
command.Parameters.AddWithValue([/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"?"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2], lbl3Trial3.Text);
command.Parameters.AddWithValue([/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"?"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2], lbl4Trial3.Text);
command.Parameters.AddWithValue([/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"?"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2], lbl5Trial3.Text);
command.Parameters.AddWithValue([/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"?"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2], lbl6Trial3.Text);
command.Parameters.AddWithValue([/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"?"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2], lblStartdate.Text);
command.Parameters.AddWithValue([/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"?"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2], lblEndDate.Text);
command.ExecuteNonQuery();
connection.Close();
[/SIZE]

But when I debug, there's an error " The field is too small to accept the amount of data you attempted to add. Try inserting or pasting less data. "

Any help please? :( :confused: Thank you!
 

DCrake

Remembered
Local time
Today, 19:33
Joined
Jun 8, 2005
Messages
8,632
This usually means that you are attempting to paste a sting into a field that is longer than the field setting. The field may be set to 50 characters and you ar trying to paste more than 50.
 

Users who are viewing this thread

Top Bottom