The field is too small to accept the amount of data you attempted to add. Try insert-VBForums
Results 1 to 2 of 2

Thread: The field is too small to accept the amount of data you attempted to add. Try insert

  1. #1

    Thread Starter
    Member
    Join Date
    Nov 2006
    Posts
    52

    The field is too small to accept the amount of data you attempted to add. Try insert

    I am using an Access 2000 database with Visual Basic 2008 Express.

    When I try to change a record, the code works fine. When I try to insert a record, I get the error shown in the title.

    The Access query "Update" works fine. the Access query "Insert" causes the error, The parameters in the Visual Basic program are identical. I am at a complete loss as to how I can locate the cause of the error. The error message gives no indication ofwhere the problem comes from in the 20parameters that are set up.

    The only thing that I can think of is the way I set up the parameters because the Access query works fine in Access. the parameters I use are as follows:

    objData.AddParameter("@EmployeeID", OleDbType.VarChar, 4, txtEmployeeID.Text)
    objData.AddParameter("@UserPwd", OleDbType.VarChar, 30, txtUserPwd.Text)
    objData.AddParameter("@LName", OleDbType.VarChar, 30, txtLastName.Text)
    objData.AddParameter("@FName", OleDbType.VarChar, 30, txtFirstName.Text)
    objData.AddParameter("@DisplayName", OleDbType.VarChar, 65, txtDisplayName.Text)
    objData.AddParameter("@Address", OleDbType.VarChar, 50, txtAddress.Text)
    objData.AddParameter("@City", OleDbType.VarChar, 50, txtCity.Text)
    objData.AddParameter("@State", OleDbType.VarChar, 2, txtState.Text)
    objData.AddParameter("@Zip", OleDbType.VarChar, 10, txtZip.Text)
    objData.AddParameter("@Gender", OleDbType.VarChar, 1, txtGender.Text)
    objData.AddParameter("@Phone", OleDbType.VarChar, 14, txtPhone.Text)
    objData.AddParameter("@Cell", OleDbType.VarChar, 14, txtCell.Text)
    objData.AddParameter("@BirthDate", OleDbType.Date, 8, dtpBirthDate.Text)
    objData.AddParameter("@CanChange", OleDbType.Integer, 2, intCanChange)
    objData.AddParameter("@TSRequired", OleDbType.Integer, 2, intTSRequired)
    objData.AddParameter("@PBT", OleDbType.Integer, 2, intPBT)
    objData.AddParameter("@PBTBase", OleDbType.Double, 8, dblPBTBase)
    objData.AddParameter("@StartDate", OleDbType.Date, 8, dtpStartDate.Text)
    objData.AddParameter("@Status", OleDbType.Integer, 2, intStatus)
    objData.AddParameter("@StatusDate", OleDbType.Date, 8, dtpStatusChangeDate.Text)

    Any help would be appreciated.
    objData.AddParameter("@Email", OleDbType.VarChar, 50, txtEmail.Text)

  2. #2
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    88,656

    Re: The field is too small to accept the amount of data you attempted to add. Try insert

    It is good practice to specify a name for parameters when using Access, as you have done, but it's important to understand that those names are actually ignored by the Jet OLEDB provider. Parameters are used in the order they are added. My guess is that you have added the parameters to the command in a different order to that in which they appear in the SQL code. If you aren't sure what to do then please post both your UPDATE and INSERT SQL statements and the EXACT code you're using to add the parameters to each OleDbCommand.

    2007-2014

    Why is my data not saved to my database? | MSDN Data Walkthroughs
    MSDN "How Do I?" Videos: VB | C#
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts) | WP8 Turnstile Feather Transition with Pivot Control
    Beginner Tutorials: VB | C# | SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width

Survey posted by VBForums.