Article View: borland.public.cppbuilder.database.ado
Article #2024Re: ADO MYSQL VarChar problems
From: Jason
Date: Fri, 12 Dec 2003 00:19
Date: Fri, 12 Dec 2003 00:19
81 lines
3624 bytes
3624 bytes
If anyone else has this problem, the solution was to revert back to MyODBC
2.5 and select the "Don't optimise column width" option. For some reason
MyODBC 3.51 did not work even with the option selected.
Jason
"Jason" <jason@invarion.com> wrote in message
news:3fd80303$1@newsgroups.borland.com...
> 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:
<3fd90992$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<3fd7c4da$1@newsgroups.borland.com> <3fd80303$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-11 16:39:27 PST From: "Jason" <jason@invarion.com> Newsgroups: borland.public.cppbuilder.database.ado References: <3fd7c4da$1@newsgroups.borland.com> <3fd80303$1@newsgroups.borland.com> Subject: Re: ADO MYSQL VarChar problems Date: Fri, 12 Dec 2003 11:19:38 +1100 Lines: 83 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: <3fd90992$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1071188370 202.174.228.150 (11 Dec 2003 16:19:30 -0700) Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail