Παρασκευή 2 Μαρτίου 2012

Create a table including an AutoInc field (ADO/MSSQL)

 
// Creates a Table called MYTABLENAME with a unique identifier called
// "ID". ID increases with every new row automatically. MYTEXT1 and 2
// are Strings. Name the colums as you want to.
// I used the ADOConnection to access a MS-Access Database (*.mdb)
// via Jet 4.0.
// The Syntax is MSSQL, you have to transform it to use it in PHP or so.



uses AdoDB;

var
  
q: TAdoQuery;
  db: TAdoConnection;
begin

    
// Initialize db here

    
q := TADOQuery.Create(nil);
    q.Connection := db;
    q.Close;
    q.SQL.Clear;
    q.SQL.Add('Create Table MYTABLENAME (ID COUNTER PRIMARY KEY, MYTEXT1 String, MYTEXT2 String);');
    q.Prepared := True;
    try
      
q.ExecSQL;
    except
end
;
    q.Free;

end;

Δεν υπάρχουν σχόλια:

Δημοσίευση σχολίου