Problème création de tables dans MS ACCESS
Bonjour à tous
Après avoir créé la BD par le code :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
| result:= FileExists(CurDBPath);
if not result then
begin
Screen.Cursor:= crHourGlass;
chaineCnx :=
'Provider=Microsoft.Jet.OLEDB.4.0;' +
'User ID=Admin;' +
'Data Source=' + CurDBPath + ';' +
'Mode=Share Deny None;Extended Properties="";' +
'Jet OLEDB:Engine Type=5;';
Cat := CreateOleObject('ADOX.Catalog');
Cat.Create(chaineCnx);
// Libération
Cat := Unassigned;
TablesCreate;
end; |
je souhaite créer les tables par la fonction TablesCreate :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
| // Création des tables
procedure TBD.TablesCreate;
var
req : string;
PW: Integer;
begin
PW:= PassWordToInteger('admin');
if ADOConnection1.Connected then ADOConnection1.Close;
ADOConnection1.ConnectionString := Format(_ConnString,[_UserName,_PassWord,CurDBPath]);
ADOConnection1.LoginPrompt := False;
ADOConnection1.Connected := True;
ADOCommand1.Connection := ADOConnection1;
//************************************************************* table ADMIN
// Dans cette version l'administrateur est unique
// 1 ********************************************************** table ADMIN
req:= 'CREATE TABLE ADMIN (' +
' AdNo AUTOINCREMENT, ' + // Clé primaire autoincrémentée
' PRIMARY KEY (AdNo), '+
' Pass INTEGER NOT NULL DEFAULT '+IntToStr(PW)+', ' + // "admin" crypté
' Rights INTEGER NOT NULL DEFAULT '+IntToStr(DA_All)+', ' + // all rights
' UserName VARCHAR(32) NOT NULL, ' +
' Used VARCHAR(2) DEFAULT -1 '+
')';
ADOCommand1.CommandText := req;
ADOCommand1.Execute; |
L'exécutable se plante systématiquement à la ligne 8 en déclenchant une EAccessViolation
J'ai du sauter un chapitre !!! Lequel ?
Ok j'ai tout ce qu'il ma faut. Merci