Article View: borland.public.cppbuilder.database.ado
Article #2006Re: ADO MYSQL VarChar problems
From: Jason
Date: Thu, 11 Dec 2003 05:39
Date: Thu, 11 Dec 2003 05:39
62 lines
3216 bytes
3216 bytes
Have further narrowed this problem down in that I realised the number of
characters cannot exceed the longest string already in the database for that
field. I directly entered a value into the database using SQL insert and
noticed that once I had done that I could enter strings of a length up to
that size from within my program.
It seems that it is determining field size based on records in the dataset?
Jason
"Jason" <jason@invarion.com> wrote in message
news:3fd7c4da$1@newsgroups.borland.com...
> Hi there!
>
> I am writing a database application that connects to a MYSQL server using
> the MYODBC provider. Most things are working okay but I am having a
problem
> with VarChar (and Char) fields in that they seem to be chopping off when
> they reach a certain point in the string I am trying to store. For
example,
> if I try to store the string "what is going on?" only "what is goi" is put
> into the database.
>
> The table is of type MYISAM. I have also tried INNODB. The field is
defined
> as:
>
> username VARCHAR (50)
>
> I have tried other VarChar fields in my database and they all seem to have
> the same problem. The code I am using to set and post the String is as
> follows:
>
> String DBTest = "what is going on?";
> tblUsers->Insert();
> tblUsers->FieldByName("username")->AsString = DBTest;
> tblUsers->Post();
> String DBCheck = tblUsers->FieldByName("username")->AsString;
>
> In the above example, DBCheck evaluates as "what is goi".
>
> I have also tried placing a check right after I assign the field to
DBTest,
> before posting the value, and at this stage the value in the field is also
> just "what is goi". I assumed the (50) in the field definition indicated a
> length of 50 characters but incase I was wrong, I changed the length to
150
> and then 200. This did not solve the problem. I used the following sql on
> the server to change the length:
>
> alter table tblUsers modify username VarChar(200);
>
> My ADOTable has no persistant field defs. At this stage I'm not sure what
is
> causing the problem or how it can be fixed. Any insights into what I am
> doing wrong would be appreciated.
>
> Thankyou,
> Jason Shrapnel
> Invarion Pty Ltd
>
>
Technical Details
Message-ID:
<3fd80303$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!newsfeed2.dallas1.level3.net!news.level3.com!news-out.visi.com!petbe.visi.com!newsfeed.media.kyoto-u.ac.jp!newsfeed01.tsnz.net!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mailReferences:
<3fd7c4da$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10698b,3a37184492ecada7 X-Google-Attributes: gid10698b,public X-Google-ArrivalTime: 2003-12-10 21:49:12 PST From: "Jason" <jason@invarion.com> Newsgroups: borland.public.cppbuilder.database.ado References: <3fd7c4da$1@newsgroups.borland.com> Subject: Re: ADO MYSQL VarChar problems Date: Thu, 11 Dec 2003 16:39:22 +1100 Lines: 64 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1106 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 NNTP-Posting-Host: 202.174.228.150 Message-ID: <3fd80303$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1071121155 202.174.228.150 (10 Dec 2003 21:39:15 -0700) Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!newsfeed2.dallas1.level3.net!news.level3.com!news-out.visi.com!petbe.visi.com!newsfeed.media.kyoto-u.ac.jp!newsfeed01.tsnz.net!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail