Page 1 of 1

How to use InsertRecord with TMyTable?

Posted: Thu 14 Apr 2011 12:12
by frangarrob
Hello, anybody knows how to use de InsertRecord command with the TMyTable component?

I don't know what arguments i need to put into de brackets. I need to insert a new empty record in my database with my application.

Form.TMyTable.InsertRecord();

When I make it, How can I go to this blank record and how can I put values into the fields and save it?

Thanks.

Posted: Thu 14 Apr 2011 15:07
by AndreyZ
Hello,

You can use one of the following ways to insert records (the result will be the same):

Code: Select all

MyTable.Insert; 
MyTable.FieldByName('integer_field').AsInteger := 1;
MyTable.FieldByName('string_field').AsString := 'test';
MyTable.Post;
or

Code: Select all

MyTable.InsertRecord([1, 'test']);