怎样实现数据库自动插入一列,同时要改变数据源,谢谢先!!!!(100分)

  • 主题发起人 主题发起人 TomZhao
  • 开始时间 开始时间
T

TomZhao

Unregistered / Unconfirmed
GUEST, unregistred user!
怎样实现数据库自动插入一列,同时要改变数据源,谢谢先!!!![:D]
 
先把表关闭,再打开,只有这样
 
你讲的什么意思,可否在具体些?
 
to antic_ant 要是怎么简单我就不发帖了
用ADOQUERY 查询出结果根据用户选择动态增加字段,并向数据库中增加相应列,
用于汇总统计。
 
procedure TFormMain.TreeView_ChannelClick(Sender: TObject);
var
TreeNode: TTreeNode;
begin
Screen.Cursor := StartCursor;
if (Sender as TTreeView).Selected <> nil then
begin
TreeNode := (Sender as TTreeView).Selected;
if PointTypeAndID(TreeNode.Data)^.TypeType = 'CHANNEL_ALL' then
begin
with DataModule1.ClientDataSet1 do
begin
Close;
CommandText := 'Select ' + Field_Channel + ', Channel_ID From CHANNEL_CODE, CHANNEL_CATEGORY WHERE CHANNEL_CODE.CATEGORY_ID = CHANNEL_CATEGORY.CATEGORY_ID ORDER BY CHANNEL_NAME';
Open;
end;
ShowListView_Channel(DataModule1.ClientDataSet1, ListView_Channel, ICO_CHANNEL_CODE);
StatusBar_Main.Panels[0].Text := '频道信息';
NoteBook_ListView.ActivePage := 'Channel';
end;

if PointTypeAndID(TreeNode.Data)^.TypeType = 'CHANNEL_CATEGORY' then
begin
with DataModule1.ClientDataSet1 do
begin
Close;
CommandText := Format('Select ' + Field_Channel + ', Channel_ID From CHANNEL_CODE, CHANNEL_CATEGORY WHERE CHANNEL_CODE.CATEGORY_ID = CHANNEL_CATEGORY.CATEGORY_ID AND CHANNEL_CODE.CATEGORY_ID = ''%s'' ORDER BY CHANNEL_NAME', [PointTypeAndID(TreeNode.Data)^.TypeID]);
Open;
end;
ShowListView_Channel(DataModule1.ClientDataSet1, ListView_Channel, ICO_CHANNEL_CODE);
StatusBar_Main.Panels[0].Text := '频道信息';
NoteBook_ListView.ActivePage := 'Channel';
end;
end;
Screen.Cursor := EndCursor;
end;

Field_Channel : String;

Field_Channel := GetFieldString(ContentPath + ListView_Channel_File);

function GetFieldString(FileName: String): String;
var
StringList, StringList1: TStringList;
S: String;
i: Integer;
begin
S := '';
StringList := TStringList.Create;
StringList1 := TStringList.Create;
StringList.LoadFromFile(FileName);
for i := 0 to StringList.Count - 1 do
begin
SeparateString(StringList, '^', StringList1);
if StringList1[3] = 'Y' then
S := S + StringList1[1] + ', ';
end;
S := Copy(S, 1, Length(S) - 2) + ' ';
StringList.Free;
StringList1.Free;
Result := S;
end;

procedure SeparateString(S, Sign: String; StringList: TStringList);
var
Count: Integer;
begin
StringList.Clear;
repeat
Count := Pos(Sign, S);
StringList.Add(Copy(S, 1, Count -1));
S := Copy(S, Count + 1, Length(S) - Count);
until StrPos(PChar(S), PChar(Sign)) = nil;
StringList.Add(S);
end;
 

Similar threads

回复
0
查看
978
不得闲
S
回复
0
查看
835
SUNSTONE的Delphi笔记
S
S
回复
0
查看
765
SUNSTONE的Delphi笔记
S
后退
顶部