BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Update half words to the database

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> comp.lang.pascal.delphi.databases
View previous topic :: View next topic  
Author Message
Jean Botes
Guest





PostPosted: Wed Jan 05, 2005 7:17 am    Post subject: Update half words to the database Reply with quote



Hi,

I have a problem with my sql updates. I use label and edit boxes and
parameterised queries and when I do some insert and updates for some reason
only half the word is updated to the database.

eg. should insert 'black vneck' but inserts 'black vne'.

I see in my logs that that is what is send to the parameters but I don't
understand why.

I'm using Delphi 7 with MySQL.

Any help will be apreciated!

Thanks
Jean


Back to top
HH
Guest





PostPosted: Wed Jan 05, 2005 9:00 am    Post subject: Re: Update half words to the database Reply with quote



Jean Botes wrote:
Quote:

for some reason only half the word is updated to the database.

eg. should insert 'black vneck' but inserts 'black vne'.


Without seeing any of your code and the SQL sentence you use, it is
quite impossible to quess what could be the reason.

Maybe you are just using somewhere too short String variables to
transfer that data to the database. You could have defined some String
like:
var
MyString :String[9];

That kind of String would hold and transfer only first 9 characters, and
lead to 'black vne' type results.

That was quite a weak quess. But without better starting data, that was
all I could get out.

Back to top
Jean Botes
Guest





PostPosted: Wed Jan 05, 2005 12:12 pm    Post subject: Re: Update half words to the database Reply with quote



Hi,

here is a code sniplet. my database character lenght is long enough as some
of the updates are correct.

eg. insert
pep vneck
pep vneck
pep vneck
pep vne
pep vne
pep vneck
pep vneck
pep vnec
etc...

have a look.

Thanks!

procedure InsertInventory;
var Colour, Quality : String;

begin
SelectQPS; {retrieves the quality of panels and sleeves}
if frmCreatePS.dbtQPanels.Caption = '1st' then
Quality := '1st'
else if frmCreatePS.dbtQSleeves.Caption = '1st' then
Quality := '1st'
else Quality := frmCreatePS.dbcmbQuality.Text;

if frmCreatePS.edtColour.Text <> '' then
Colour := frmCreatePS.edtColour.Text
else
Colour := frmCreatePS.dbcmbColour.Text;

dm.qInsertInventory.Close;

dm.qInsertInventory.Params.ParamValues['date_created;type;quality;dye;stock_
nr;colour;size;quantity;department'] :=
VarArrayOf([frmCreatePS.edtDate.Text,
lowercase(frmCreatePS.dbcmbType.Text),
lowercase(Quality),
frmCreatePS.edtDye.Text,
frmCreatePS.edtStockNr.Text,
lowercase(Colour),
frmCreatePS.edtSize.Text,
frmCreatePS.edtQuantity.Text,
'Production']);
if not dm.qInsertInventory.Prepared then
dm.qInsertInventory.Prepare;
try
dm.qInsertInventory.ExecSQL;
except On e : EDatabaseError do messageDlg(e.message, mtError,
[mbOK],0);
end;
end;


"HH" <hh (AT) yourcompany (DOT) domain> wrote

Quote:
Jean Botes wrote:

for some reason only half the word is updated to the database.

eg. should insert 'black vneck' but inserts 'black vne'.


Without seeing any of your code and the SQL sentence you use, it is
quite impossible to quess what could be the reason.

Maybe you are just using somewhere too short String variables to
transfer that data to the database. You could have defined some String
like:
var
MyString :String[9];

That kind of String would hold and transfer only first 9 characters, and
lead to 'black vne' type results.

That was quite a weak quess. But without better starting data, that was
all I could get out.





Back to top
HH
Guest





PostPosted: Wed Jan 05, 2005 1:52 pm    Post subject: Re: Update half words to the database Reply with quote

Jean Botes wrote:
Quote:

dm.qInsertInventory.Params.ParamValues['date_created;type;quality;dye;stock_
nr;colour;size;quantity;department'] :=

The word 'size' is a reserved word at least with some ODBC-drivers. But
I'm not sure if that's the actual reason here.

Quote:
VarArrayOf([frmCreatePS.edtDate.Text,
lowercase(frmCreatePS.dbcmbType.Text),
lowercase(Quality),
frmCreatePS.edtDye.Text,
frmCreatePS.edtStockNr.Text,
lowercase(Colour),
frmCreatePS.edtSize.Text,
frmCreatePS.edtQuantity.Text,
'Production']);
if not dm.qInsertInventory.Prepared then
dm.qInsertInventory.Prepare;

I would probably start debugging by first adding all those TEdit
vadiable contenst to some temporary string variables, and then use them
with this query. That way you could see if the problem has anything to
do with those TEdit control contents not being transferred completely.

Also I do not see your SQL sentence here at all, the problem may as well
reside somewhere in there.
I have used this simple procedure for years, when I want to get my
dynamically created SQL sentences and Parameters saved to a disk file.
It's easier to check and find the errors when yoo see the whole SQL at a
glance.

procedure TForm1.WriteQueryParamsToFile(aQuery: TQuery; FN:String);
{For Development time and TEST purposes only.
Write Query's SQL sentence and all the Parameters to
a disk file.
USAGE: WriteQueryParamsToFile(MyQuery,'C:TestFil'); }
var
i:Integer;
SL:TStringList;
begin
SL := TStringList.Create;
try
SL.Assign(aQuery.SQL);
SL.Insert(0, '<Query> = ' +aQuery.Name); { Add Query's name to}
SL.Add(''); { the output file. }
SL.Add('<Parameters>'); { Add Query's parameter
list.}
for i:=0 to aQuery.Params.Count-1 do
SL.Add(Format('%S=%S',[aQuery.Params[i].Name,
aQuery.Params[i].AsString]));
SL.SaveToFile(FN);
finally
SL.Free;
end;
end;

Sorry, no better tips this time. As I have no time to start test
anything with your query.

Back to top
Jean Botes
Guest





PostPosted: Thu Jan 06, 2005 6:27 am    Post subject: Re: Update half words to the database Reply with quote

Hi

Thanks, I renamed all the variables and added a 'p' in front (e.g ptype,
psize). I'm busy testing and hasn't found anything wrong.

Jean

"HH" <hh (AT) yourcompany (DOT) domain> wrote

Quote:
Jean Botes wrote:


dm.qInsertInventory.Params.ParamValues['date_created;type;quality;dye;stock_
nr;colour;size;quantity;department'] :=

The word 'size' is a reserved word at least with some ODBC-drivers. But
I'm not sure if that's the actual reason here.

VarArrayOf([frmCreatePS.edtDate.Text,
lowercase(frmCreatePS.dbcmbType.Text),
lowercase(Quality),
frmCreatePS.edtDye.Text,
frmCreatePS.edtStockNr.Text,
lowercase(Colour),
frmCreatePS.edtSize.Text,
frmCreatePS.edtQuantity.Text,
'Production']);
if not dm.qInsertInventory.Prepared then
dm.qInsertInventory.Prepare;

I would probably start debugging by first adding all those TEdit
vadiable contenst to some temporary string variables, and then use them
with this query. That way you could see if the problem has anything to
do with those TEdit control contents not being transferred completely.

Also I do not see your SQL sentence here at all, the problem may as well
reside somewhere in there.
I have used this simple procedure for years, when I want to get my
dynamically created SQL sentences and Parameters saved to a disk file.
It's easier to check and find the errors when yoo see the whole SQL at a
glance.

procedure TForm1.WriteQueryParamsToFile(aQuery: TQuery; FN:String);
{For Development time and TEST purposes only.
Write Query's SQL sentence and all the Parameters to
a disk file.
USAGE: WriteQueryParamsToFile(MyQuery,'C:TestFil'); }
var
i:Integer;
SL:TStringList;
begin
SL := TStringList.Create;
try
SL.Assign(aQuery.SQL);
SL.Insert(0, '<Query> = ' +aQuery.Name); { Add Query's name to}
SL.Add(''); { the output file. }
SL.Add('<Parameters>'); { Add Query's parameter
list.}
for i:=0 to aQuery.Params.Count-1 do
SL.Add(Format('%S=%S',[aQuery.Params[i].Name,
aQuery.Params[i].AsString]));
SL.SaveToFile(FN);
finally
SL.Free;
end;
end;

Sorry, no better tips this time. As I have no time to start test
anything with your query.



Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> comp.lang.pascal.delphi.databases All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.