Results 1 to 3 of 3

Thread: [RESOLVED]Strange problem when saving records

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Nov 2004
    Posts
    1,414

    Resolved [RESOLVED]Strange problem when saving records

    hi to all:

    This code i had use for create a field in DB Access 2003:

    Code:
     SQL = "ALTER TABLE plano_contas ADD declperiodica06A char(40) WITH COMPRESSION NULL)"
            Dim command1 As New OleDb.OleDbCommand(SQL, con1)
            con1.Open()
            command1.ExecuteNonQuery()
            con1.Close()
    like you see the code create a Text field with 40 lenght...
    Well the problem is:
    When i save a new record the record it's save in this mode:
    "100..................................." - the points means spaces
    and should be:
    "100"

    After try a lot of things i'm without more solutions in find why this happen!
    Someone can give me some help here?

    Thanks
    Last edited by sacramento; Jan 12th, 2010 at 07:19 AM.

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Strange problem when saving records

    Try using varchar instead of char. char is a fixed-width data-type, so all values are padded out to the specified width if they are not that size to begin with.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Nov 2004
    Posts
    1,414

    Re: Strange problem when saving records

    hi jmcilhinney:

    Yes...you are right...varchar resolve the problem


    Thanks a lot

Posting Permissions

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



Click Here to Expand Forum to Full Width