DATABASE NAME= USER NAME= ODBC DSN= OPEN MODE=READ/WRITE SCHEMA CACHE SIZE=8 SQLQRYMODE= LANGDRIVER= SQLPASSTHRU MODE=SHARED AUTOCOMMIT SCHEMA CACHE TIME=-1 MAX ROWS=-1 BATCH COUNT=200 ENABLE SCHEMA CACHE=FALSE SCHEMA CACHE DIR= ENABLE BCD=FALSE ROWSET SIZE=20 BLOBS TO CACHE=64 PASSWORD= 都应该填写什么
procedure TForm1.importBtnClick(Sender: TObject); var I,J,k,Row,Col,sRow,sCol: integer; ExcelFile: string; TmpString: String; begin ExcelFile := Trim(Edit1.Text); Row := strtoint(Edit4.Text); //the total Rows Col := strtoint(Edit5.Text); //the total Columns sRow := strtoint(Edit2.Text); //the start of Row sCol := strtoint(Edit3.Text); //the start of Column try if VarIsEmpty(XlsApp) then XlsApp := CreateOleObject('Excel.Application'); XlsSheet := XlsApp.workbooks.open(ExcelFile); for I := sRow to (sRow + Row) - 1 do //from the start row to the end row begin k := 0; //the item of the field TmpString := ''; Table1.open; Table1.Append; for J := sCol to (sCol + Col) - 1 do //from the start column to the end column begin TmpString := XlsSheet.ActiveSheet.Cells[I,J].Text; Table1.Fields[k].AsString := TmpString; k := k + 1; end; Table1.Post; end; XlsApp.Visible := true; except XlsSheet.close; XlsApp.Application.quit; XlsApp := Unassigned; XlsSheet := Unassigned; end; end;
通过BDE或ADO配置数据库引擎,通过一个TTAble,TQuery.TADODataSet等控件将其读出来 Tquery and tadodataset 都要cmdtxt我的sql该怎么写
USER NAME=
ODBC DSN=
OPEN MODE=READ/WRITE
SCHEMA CACHE SIZE=8
SQLQRYMODE=
LANGDRIVER=
SQLPASSTHRU MODE=SHARED AUTOCOMMIT
SCHEMA CACHE TIME=-1
MAX ROWS=-1
BATCH COUNT=200
ENABLE SCHEMA CACHE=FALSE
SCHEMA CACHE DIR=
ENABLE BCD=FALSE
ROWSET SIZE=20
BLOBS TO CACHE=64
PASSWORD=
都应该填写什么
var
I,J,k,Row,Col,sRow,sCol: integer;
ExcelFile: string;
TmpString: String;
begin
ExcelFile := Trim(Edit1.Text);
Row := strtoint(Edit4.Text); //the total Rows
Col := strtoint(Edit5.Text); //the total Columns
sRow := strtoint(Edit2.Text); //the start of Row
sCol := strtoint(Edit3.Text); //the start of Column
try
if VarIsEmpty(XlsApp) then
XlsApp := CreateOleObject('Excel.Application');
XlsSheet := XlsApp.workbooks.open(ExcelFile);
for I := sRow to (sRow + Row) - 1 do //from the start row to the end row
begin
k := 0; //the item of the field
TmpString := '';
Table1.open;
Table1.Append;
for J := sCol to (sCol + Col) - 1 do //from the start column to the end column
begin
TmpString := XlsSheet.ActiveSheet.Cells[I,J].Text;
Table1.Fields[k].AsString := TmpString;
k := k + 1;
end;
Table1.Post;
end;
XlsApp.Visible := true;
except
XlsSheet.close;
XlsApp.Application.quit;
XlsApp := Unassigned;
XlsSheet := Unassigned;
end;
end;
Tquery and tadodataset 都要cmdtxt我的sql该怎么写
用Ttable tablename是什么??
mengbo(心有独钟) 思路是创建一个excel ole对象,用它来打开excel文件
读取当前激活表页的每一个单元格,并插入到对应的字段中,完成一行提交一次也是一种办法adoconnection.connectionString='Provider=MSDASQL.1;Persist Security Info=False;Mode=Read;Extended Properties="DSN=Excel Files;DBQ=C:\;DriverId=790;MaxBufferSize=2048;PageTimeout=5;"';
用adoquery.connection:=adoconnection;
adoQuery.SQL:='select * from [sheet1!]';以上是核心的几句伪代码
谢谢!!!!!!!!!
提示:invalid bracketing of name 'sheet1!'
[sheet1!]是什么含义;
平时写sql的时候,from + 表名,[sheet1!]是什么东东
ADOQuery.connectionString:='Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\bk.xls;Extended Properties=Excel 8.0;Mode=ReadWrite|Share Deny None;Persist Security Info=False';
ADOQuery.sql.text:='select * from [Sheet1$]';
ADOQuery.open;
数据会缺少如下:
我
你
他
12
那么数字12不会被tquery接收,这是怎么回事,怎么解决
从tquery中读出数据的时候showmessage(adoquery1.fields[i].asstring)
到12的时候,是空的
或者使用逐个单元读出的方法ps:你可以要求数据提供者提供规范的数据