Thanks
insert data, help me.
insert data, help me.
hello I am new to Delphi. i want to insert new record to mysql database but don't know how. the connection using mysqlaccess is success but i don't know which components to use to insert data. i just want to insert several data and put it into a database, no need to display it meaning i don't want to use navigator or dbgrid. i just want to click on the enter button and the data will go straight to the database. can someone pls help me what components to use and where to put the statement?
Thanks
			
									
									
						Thanks
You can use TMyCommand component to insert data using your statement.
For example:
You can also use TMyQuery, and INSERT, UPDATE, DELETE and REFRESH statements will be generated automatically:
			
									
									
						For example:
Code: Select all
var
  MyCommand: TMyCommand;
...
  MyCommand.SQL.Text := 'insert into TableName(ID, c_int) values(10, 20)';
  MyCommand.Execute;Code: Select all
var
  MyQuery: TMyQuery;
...
  MyQuery.SQL.Text := 'select * from TableName';
  MyQuery.Open;
  MyQuery.Insert;
  MyQuery.FieldByName('ID').AsInteger := 10;
  MyQuery.FieldByName('c_int').AsInteger := 20;
  MyQuery.Post;