1

(4 replies, posted in General)

Ok some more beginners troubles.

I'm trying to insert a record into a simple table.  I was able to do it with the following code:

var
  DB TSqlitePassDatabase;
  SQL : String;

begin
// insert new record into database
SQL := 'INSERT INTO Runners ( username, name, salt, passhash ) values(''' + UserName + ''',''' + FullName + ''',''' + Salt + ''',''' + PassHash + ''')';
DB.Engine.Exec( SQL, nil  );
end

For some reason I've a feeling this isn't the best way to do it.  Do you have any other suggestions on how to insert a record in a table?

2

(4 replies, posted in General)

Thanks for you response,
I found the problem.  I didn't have the DatabaseType set correctly.  When I set it to dtSqliteAdmin and it started working.  I noticed that there are two different sqlite type 'dtSqliteAdmin' and 'dtSqlitePass' what's the difference? Also discovered that when I  tried to access a field that came back NULL it would throw an exception.  So I'll add some exception handlers. 

I quite like this control you've written you've done a good job.  I'd be happy to help out with testing and expanding the example base.

Thanks,

Barefoot Brian

3

(4 replies, posted in General)

I'm having some problem getting the fields to show up in my queries with the following code:

// defined in the unit
var
  DB TSqlitePassDatabase;
  Cur TSqlitePassDataset;

// function

procedure TForm1.FormCreate(Sender: TObject);
     DB.Open;
     Cur.SQL.Text := 'SELECT name,id,username,salt,passhash FROM Runners';
     Cur.Open;
     Cur.First;
     while not Cur.EOF do begin
           Item := UserList.Items.Add;
           try
              Memo1.Lines.Add( IntToStr( Cur.Fields.Count ) );
              Cur.Active := true;
              Item.Caption := Cur.FieldByName( 'name' ).AsString;
              Item.SubItems.Add( Cur.FieldByName( 'id' ).AsString );
              Item.SubItems.Add( Cur.FieldByName( 'username' ).AsString );
              Item.SubItems.Add( Cur.FieldByName( 'salt' ).AsString );
              Item.SubItems.Add( Cur.FieldByName( 'passhash' ).AsString );
           except
           end;
           Cur.Next;
     end;
     
     Cur.Close;
     FieldNames.Free
end;

Basically it's retrieving the expected number of records but for some reason it isn't getting any of the fields.  I've double checked my names with my sqlite db and they match.  Is there something I'm missing?

Thanks for your help

Barefoot Brian