SQLInsert

Discussion of open issues, suggestions and bugs regarding MyDAC (Data Access Components for MySQL) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
joegoh
Posts: 3
Joined: Sun 03 Aug 2008 15:05

SQLInsert

Post by joegoh » Mon 01 Sep 2008 14:30

Can you an example of how to use parameterized input with MyQuery1?
Can you illustrated?

Dimon
Devart Team
Posts: 2910
Joined: Mon 05 Mar 2007 16:32

Post by Dimon » Wed 03 Sep 2008 13:59

The example of a code for inserting record in a table:

Code: Select all

MyQuery.SQL.Text := 'INSERT INTO table_name(field1) VALUES(:field1)';
MyQuery.ParamByName('field1').AsInteger := 1;
MyQuery.Execute;

JustAnEngineer
Posts: 3
Joined: Tue 14 Oct 2008 03:57

Post by JustAnEngineer » Tue 14 Oct 2008 04:36

Hi,

I'm trying to do something quite similar, but and only getting two bytes stored, which apparently are the #13#10 at the beginning of the text data (coming out of a TStrings.Text).

The table I'm posting to has about 30 fields. Everything in the table is posting fine given the example above with the exception of one field.

The field I'm having a problem with is this:

MyHtmlField [Text, NULL]

I do the following:

Code: Select all

MyQuery.SQL.Text := 'INSERT INTO table_name(MyHtmlField) VALUES(:MyHtmlField)';
MyQuery.ParamByName('MyHtmlField').AsString := tsHTML.Text;
MyQuery.Execute;
Like I mentioned above, it's just storing two bytes. That is all. I've also tried just using a TMySqlTable and doing the regular Append...AsString...Post

Should I be escaping something? Or is there a better way to put text into a Text field? Also, I'm doing this at run-time. I'm not creating the component on a form or anything. I have the Server in the DataModule, but creating the queries at run-time.

Thanks,

Wes

JustAnEngineer
Posts: 3
Joined: Tue 14 Oct 2008 03:57

Post by JustAnEngineer » Tue 14 Oct 2008 04:43

:oops:

Forget the question. It was my fault. Your components are flawless and great!

Long Live DevArt!!

Wes

Post Reply