異構(gòu)數(shù)據(jù)庫(kù)之間的導(dǎo)入導(dǎo)出
//mssql2excel
adoconnection1.connectionstring:=
'provider=microsoft.jet.oledb.4.0;data source=g:/mysmallexe/excel2sql/yp.xls;'
+'extended properties=excel 8.0';
adoconnection1.execute('select * into [abc] from drug_yk in [odbc] [odbc;driver=sql
server;uid=sa;pwd=kcsoft58;server=127.0.0.1;database=kcsoft_his]');
//把一個(gè)mssql的數(shù)據(jù)庫(kù)表及數(shù)據(jù)導(dǎo)出到excel中,abc為excel中不存在的表名,drug_yk為mssql里的表, sa為
用戶(hù), kcsoft58為密碼 , 127.0.0.1為服務(wù)大地址 ,kcsoft_his是數(shù)據(jù)庫(kù)名稱(chēng)
adoconnection1.execute('insert into [abc] select * from drug_yk in [odbc] [odbc;driver=sql
server;uid=sa;pwd=kcsoft58;server=127.0.0.1;database=kcsoft_his]');
//把一個(gè)mssql的數(shù)據(jù)庫(kù)表的記錄增加到到excel中,執(zhí)行以后相當(dāng)于兩倍量的數(shù)據(jù),一次是導(dǎo)入,一次是
insert
//excel2mssql
adoconnection1.connectionstring:='provider=sqloledb.1;password=kcsoft58;persist security
info=true;user id=sa;initial catalog=kcsoft_his;data source=chen';
adoconnection1.execute('select * into [abc] from opendatasource( '
+quotedstr('microsoft.jet.oledb.4.0')+','
+quotedstr('data source="g:/mysmallexe/excel2sql/yp.xls";extended properties=excel 8.0')
+')...[abc]');
//mssql2vfp
adoconnection2.connectionstring:=
'provider=microsoft.jet.oledb.4.0;data source=g:/mysmallexe/excel2sql;'
+'extended properties=dbase 5.0';
adoconnection2.execute('select * into abc.dbf from drug_yk in [odbc] [odbc;driver=sql
server;uid=sa;pwd=kcsoft58;server=127.0.0.1;database=kcsoft_his]');
//把一個(gè)mssql的數(shù)據(jù)庫(kù)表及數(shù)據(jù)導(dǎo)出到vfp中,abc.dbf 為vfp中不存在的表名,drug_yk為mssql里的表, sa為
用戶(hù), kcsoft58為密碼 , 127.0.0.1為服務(wù)大地址 ,kcsoft_his是數(shù)據(jù)庫(kù)名稱(chēng)
//vfp2mssql
adoconnection2.connectionstring:='provider=sqloledb.1;password=kcsoft58;persist security
info=true;user id=sa;initial catalog=kcsoft_his;data source=chen';
adoconnection2.execute('select * into [abc] from opendatasource( '
+quotedstr('microsoft.jet.oledb.4.0')+','
+quotedstr('data source="g:/mysmallexe/excel2sql";extended properties=dbase 5.0')+')...
[abc]');
//mssql2access
adoconnection2.connectionstring:=
'provider=microsoft.jet.oledb.4.0;data source=g:/mysmallexe/excel2sql/server.mdb;'
+'persist security info=false;jet oledb:database password=happynewyear';
adoconnection2.execute('select * into abc from drug_yk in [odbc] [odbc;driver=sql
server;uid=sa;pwd=kcsoft58;server=127.0.0.1;database=kcsoft_his]');
//access2mssql
adoconnection2.connectionstring:='provider=sqloledb.1;password=kcsoft58;persist security
info=true;user id=sa;initial catalog=kcsoft_his;data source=chen';
adoconnection2.execute('select * into [abc] from opendatasource( '
+quotedstr('microsoft.jet.oledb.4.0')+','
+quotedstr('data source="g:/mysmallexe/excel2sql/server.mdb";jet oledb:database
password=happynewyear')+')...[abc]');
//excel2access
adoconnection2.connectionstring:=
'provider=microsoft.jet.oledb.4.0;data source=g:/mysmallexe/excel2sql/server.mdb;'
+'persist security info=false;jet oledb:database password=happynewyear';
adoconnection2.execute('select * into [abc] from [excel
8.0;database=g:/mysmallexe/excel2sql/yp.xls].[abc$]');
//access2excel
adoconnection2.connectionstring:=
'provider=microsoft.jet.oledb.4.0;data source=g:/mysmallexe/excel2sql/yp.xls;'
+'extended properties=excel 8.0';
adoconnection2.execute('select * into abc from
[g:/mysmallexe/excel2sql/server.mdb;pwd=happynewyear].abc');
//mssql2txt
adoconnection2.connectionstring:=
'provider=microsoft.jet.oledb.4.0;data source=g:/mysmallexe/excel2sql;'
+'extended properties=text';
adoconnection2.execute('select * into abc#txt from drug_yk in [odbc] [odbc;driver=sql
server;uid=sa;pwd=kcsoft58;server=127.0.0.1;database=kcsoft_his]');
//txt2mssql
adoconnection2.connectionstring:='provider=sqloledb.1;password=kcsoft58;persist security
info=true;user id=sa;initial catalog=kcsoft_his;data source=chen';
adoconnection2.execute('select * into [abc] from opendatasource( '
+quotedstr('microsoft.jet.oledb.4.0')+','
+quotedstr('data source="g:/mysmallexe/excel2sql";extended properties=text')+')...<
新聞熱點(diǎn)
疑難解答
圖片精選