Article View: borland.public.cppbuilder.database.ado
Article #2004ADO MYSQL VarChar problems
From: Jason
Date: Thu, 11 Dec 2003 01:14
Date: Thu, 11 Dec 2003 01:14
42 lines
2567 bytes
2567 bytes
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:
<3fd7c4da$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-mailShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10698b,3a37184492ecada7,start X-Google-Attributes: gid10698b,public X-Google-ArrivalTime: 2003-12-10 17:20:59 PST From: "Jason" <jason@invarion.com> Newsgroups: borland.public.cppbuilder.database.ado Subject: ADO MYSQL VarChar problems Date: Thu, 11 Dec 2003 12:14:08 +1100 Lines: 44 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: <3fd7c4da$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1071105242 202.174.228.150 (10 Dec 2003 17:14:02 -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