問題1:
procedure TForm1.FormCreate(Sender: TObject);
var ap:TStringList;
ret:Integer;
begin
ap:=TStringList.Create;
Session.GetTableNames('delphi','',False,False,ap);
if (ap.IndexOf('mbr_info')=-1) then
begin
Application.MessageBox('mbr_info not exsit.', 'Information', mb_OKCancel);
with table1 do
begin
active:=false;
DatabaseName:='delphi';
TableName:='mbr_info';
with FieldDefs do
begin
clear;
add('mbr_id',ftString,15,True);
add('mbr_name',ftString,30,false);
end;
with IndexDefs do
begin
clear;
Add('mbr_id_index','mbr_id',[ixPrimary,ixUnique]);
end; CreateTable;
end;
end; ap.Free;
end;
每次運行此Form1時總是提示找不到mbr_info table.為什麼?
(數據庫採用 MS SQL SERVER2000 個人版)
問題2:
procedure TForm1.Button1Click(Sender: TObject);
begin
if not table1.Active then table1.Active:=True;
table1.Append;
table1.FieldValues['mbr_id']:='myid';//Edit1.Text;
table1.FieldValues['mbr_name']:='myname';//Edit2.Text;
table1.Post;
end;當單擊 Form1.Button1 後,通過同一窗口的 DBGrid1可以查看到數據的確已經加入到 table1 中,但是通過數據庫相關工具用以下的語句卻查看到數據根本就沒有存入到database中:select * from mbr_info;
(0 row(s) affected)問題3:
執行上述問題1後,重新啟動計算機,發現table mbr_info 已經不存在.
請教各位問題出在哪裡?
procedure TForm1.FormCreate(Sender: TObject);
var ap:TStringList;
ret:Integer;
begin
ap:=TStringList.Create;
Session.GetTableNames('delphi','',False,False,ap);
if (ap.IndexOf('mbr_info')=-1) then
begin
Application.MessageBox('mbr_info not exsit.', 'Information', mb_OKCancel);
with table1 do
begin
active:=false;
DatabaseName:='delphi';
TableName:='mbr_info';
with FieldDefs do
begin
clear;
add('mbr_id',ftString,15,True);
add('mbr_name',ftString,30,false);
end;
with IndexDefs do
begin
clear;
Add('mbr_id_index','mbr_id',[ixPrimary,ixUnique]);
end; CreateTable;
end;
end; ap.Free;
end;
每次運行此Form1時總是提示找不到mbr_info table.為什麼?
(數據庫採用 MS SQL SERVER2000 個人版)
問題2:
procedure TForm1.Button1Click(Sender: TObject);
begin
if not table1.Active then table1.Active:=True;
table1.Append;
table1.FieldValues['mbr_id']:='myid';//Edit1.Text;
table1.FieldValues['mbr_name']:='myname';//Edit2.Text;
table1.Post;
end;當單擊 Form1.Button1 後,通過同一窗口的 DBGrid1可以查看到數據的確已經加入到 table1 中,但是通過數據庫相關工具用以下的語句卻查看到數據根本就沒有存入到database中:select * from mbr_info;
(0 row(s) affected)問題3:
執行上述問題1後,重新啟動計算機,發現table mbr_info 已經不存在.
請教各位問題出在哪裡?
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货