sorry,没有实战Sybase的经验。
捡着问题回答你:
2. 你最好将你的源码贴出来,这样大家一看就明白。
3. >>>Select id,age from tablename where id=(Select id from tablename where age>20)
改为 Select id,age from tablename where id in (Select id from tablename where age>20)
^^^^^^
注意是 in ,不是“=”。 试试。 假如不行,你再你的把源码贴出来会诊。 [
]
4.>>>如何将显示在dbgrid中的数据输出到EXCEL中?或者如何直接形成EXCEL表格?
这个问题以前有过的,你可以搜搜。
恰好我手头有一个,我把这个给你贴出来,你可以试试看:
--------------------------
对excel的读写:
unit UMain;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
Db, DBTables, StdCtrls, Grids, DBGrids,Excel97,Comctrls,OleCtnrs,ComObj;
type
TForm1 = class(TForm)
DBGrid1: TDBGrid;
Button1: TButton;
Button2: TButton;
DataSource1: TDataSource;
Table1: TTable;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
private
{ Private declarations }
public
XlsApp,XlsSheet,XlsWBk : Variant;
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.Button1Click(Sender: TObject);
var
I,J : integer;
begin
if VarIsEmpty(XlsApp) then
XlsApp := CreateOleObject('Excel.Application');
XLsApp.Workbooks.Add;
XlsSheet := XLsApp.Worksheets['Sheet1'];
for I := 0 to Table1.Fields.Count - 1 do
begin
XlsSheet.Cells[3,I + 1] := dbgrid1.Columns
.Title.Caption;
end;
Table1.first;
for J := 0 to Table1.RecordCount - 1 do
begin
for I := 0 to Table1.Fields.Count - 1 do
begin
XlsSheet.Cells[J + 4,I + 1] := Table1.Fields.AsString;
end;
Table1.Next;
end;
XlsApp.Visible := true;
end;
procedure TForm1.Button2Click(Sender: TObject);
var
I,J : integer;
TxtFile : TextFile;
TmpString : String;
begin
try
if VarIsEmpty(XlsApp) then
XlsApp := CreateOleObject('Excel.Application');
XlsSheet := XlsApp.workbooks.open('c:/my documents/book3.xls');
AssignFile(TxtFile,'C:/My Documents/Test.txt');
Rewrite(TxtFile);
try
for I := 3 to 21 do
begin
TmpString := '';
for J := 1 to 5 do
begin
TmpString := TmpString + XlsSheet.ActiveSheet.Cells[I,J].Text + '|';
end;
Writeln(TxtFile,Tmpstring);
end;
finally
CloseFile(TxtFile);
end;
XlsApp.Visible := true;
except
XlsSheet.close;
XlsApp.Application.quit;
XlsApp := Unassigned;
XlsSheet := Unassigned;
end;
end;
procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
if not VarIsEmpty(XlsApp) then
begin
XlsApp.DisplayAlerts := True; // 7Discard unsaved files....
try
XlsApp.Application.Quit;
except
end;
end;
end;
end.