Recent

Author Topic: SQL Database Problem  (Read 3037 times)

IndianaJones

  • Hero Member
  • *****
  • Posts: 509
SQL Database Problem
« on: August 15, 2009, 12:14:18 pm »

Hi all,

I have a problem with the database. I just want to insert a data.

The contents of the simple database is;
id - int(10) not null, auto increment
name - varchar(45)

So here is my insert code;

  try
  with SQLQuery1 do
       begin
            close;
            prepare;
            Params[1].Asstring:=DBEdit1.Text;
            execsql;
       end;
  except
        on E: EDatabaseError do
           Messagedlg(E.Message, mtInformation, [mbok], 0);
  end;

and my InsertSQL's property
INSERT INTO example (id,bscname) VALUES (:id, :bscname)

So when I try to insert a data, I get this error.
Project project1 raised exception class 'EListError' with message:
List index (1) out of bounds

Thanks     

IndianaJones

  • Hero Member
  • *****
  • Posts: 509
Re: SQL Database Problem
« Reply #1 on: August 15, 2009, 06:24:47 pm »

Hi all,

I solved the mentioned problem, but get another problem.
After connecting to the database, I want to execute the following commands

            SQLQuery1.SQL.Clear;
            SQLQuery1.SQL.Add('select * from exam');
            SQLQuery1.Open;

I fill the DBGrid fields, but when I execute the program, DBGrid area is empty.
What could be the problem?
Thanks.

 

TinyPortal © 2005-2018