Delphi Excel to Sql Server
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls, Grids, DBGrids, DB, ADODB,comobj, OleServer,
ExcelXP;
type
TForm1 = class(TForm)
ADOConn: TADOConnection;
atblXlsToSql: TADOTable;
DBGrid1: TDBGrid;
Panel1: TPanel;
Button1: TButton;
opdExcel: TOpenDialog;
DataSource1: TDataSource;
Excel: TExcelApplication;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
function ConnectDB:boolean; //连接数据库
function OpenTable(const Tablename:String):boolean; //打开指定数据表
function XlsToSqlTable(const xlsFileName,TableName:String):boolean; //将Excel数据导入Sql Server
public
{ Public declarations }
end;
var
Form1: TForm1;
serverIP,dbName,userid,passw:string; //服务器IP,数据库名称,用户名,密码
implementation
{$R *.dfm}
function TForm1.ConnectDB:boolean;
begin
Result:=false;
serverIP:='192.168.0.0';
dbName:='OnLine';
userid:='sa';
passw:='sa';
if not adoconn.Connected then
begin
adoconn.ConnectionString:='Provider=SQLOLEDB.1;Password=' + passw
+ ';Persist Security Info=True;User ID=' + userid
+ ';Initial Ca
相关文档:
procedure TForm_BaseMDI.FormKeyPress(Sender: TObject; var Key: Char);
begin
if Key = #13 then
begin
Key := #0;
SendMessage(Handle, 48384, 9, 0);
end;
end; ......
《Delphi下深入Windows核心编程》(附录A Delphi编译指令说明)
摘抄人:麻子 qq:71892967
Delphi快速高小的编译器主要来自Object PASCAL的严谨,使用Delphi随时都在与编译器交流,大部分情况下不需要干涉编译器的运行,但是有时也需要对编译器进行必要的设置。
*************************************************** ......
发布一个实用小工具,可以很方便的在数据库中找到包含指定字符串的数据表名及相应记录:
/*
功能:查询数据库中包含指定字符串的数据表名及相应记录
作者:陈加鹏 chjpeng#163.com
日期:2009-08-17
*/
declare @key varchar(30)
set @key = 'test' --替换为要查找的字符串
DECLARE @ ......
select ID,Item1,Item2,Item3,Item4
into #Temp
from (
select ID='200910',Item1='A',Item2='B',Item3='C',Item4='T1'
union all
select ID='200910',Item1='',Item2='B',Item3='C' ,Item4='G2'
union all
select ID='200910',Item1='A',Item2='D',Item3='C' ,Item4='T3'
union all
select ID='200910',Item ......