Using SQL statements to import DBF into SQL Server directly

Source: Internet
Author: User
Tags dbase

Directly using SQL statements to import DBF into SQL Server execute SELECT * into BMK from OpenDataSource (' microsoft.jet.oledb.4.0 ', ' Data source= ' e: Share "; User id=admin; password=; Extended properties=dbase 5.0 ') ... bmk you can import e:share tables from bmk.dbf into SQL Server with the fastest speed

----------------------------

DBF----> SQL SERVER drop table dbf SELECT * to DBF from OpenDataSource (' microsoft.jet.oledb.4.0 ', ' Data source= ' E:su Perdatasuperdate_ Power Outage Rehearsal rundataengine Donghai project merger "; User id=; password=; Extended properties=dbase 5.0 ') ... dbf go

------------------------------------------------------success

EXCEL----> SQL SERVER

SELECT * into Yourtablename from OPENROWSET (' msdasql.1 ', ' Driver=microsoft Excel driver (*.xls);D Bq=d:excelbook2.xls ', ' SELECT * FROM [sheet1$] ')

------------------------------------------------success

Access---->sql Server INSERT into Access SELECT * to access from OpenDataSource (' microsoft.jet.oledb.4.0 ', ' Data Sou Rce= "D:mapx_web.mdb"; Jet oledb:database password= ') ... Layer_styleindex----------------------------------------------Success

Function tform1.boolean_excel_to_sqlserver_usingstringlist (p_str_machinename:string; P_str_databasename: String; p_str_username:string; p_str_password:string; P_stringlist_filenameandpath:tstringlist; P_progressbar:tprogressbar): Boolean; var//False: Operation failed m_adoconnection:tadoconnection; m_str_filenameandpath:string; m_str_filename:string; m_str_pathname:string; m_strsql:string; m_strsql1:string; M_integer_itempos:integer; Begin M_adoconnection: = Tadoconnection.create (nil); M_adoconnection.connectionstring: = ' provider=sqloledb.1; ' + ' password= ' + P_str_password + '; ' + ' Persist Security info=t Rue; ' + ' User id= ' + p_str_username + '; ' + ' Initial catalog= ' + p_str_databasename + '; ' + ' Data source= ' + p_str_machine Name; M_adoconnection.loginprompt: = false; Try//Connect database server m_adoconnection.connected: = true; Except ShowMessage (' Boolean_dbf_to_sqlserver ():: Database connection Error! ‘); Result: = false; Exit; End;

If P_progressbar <> nil then begin p_progressbar.min: = 0; P_progressbar.max: = P_stringlist_filenameandpath.count; End For m_integer_itempos: = 1 to P_stringlist_filenameandpath.count do begin m_str_filenameandpath: = P_stringlist_ FILENAMEANDPATH.STRINGS[M_INTEGER_ITEMPOS-1]; M_str_filename: = Self.string_getfilenamefromonefullfilescript (M_str_filenameandpath); M_str_filename: = Self.string_deleteextnameforonefilename (M_str_filename); M_str_pathname: = Self.string_getfilepathfromonefullfilescript (M_str_filenameandpath); M_strsql: = ' drop table ' + m_str_filename; Try//delete the corresponding original table (if any) in SQL Server M_adoconnection.execute (M_STRSQL); except end; {m_strsql: = ' SELECT * to ' + M_str_filename + ' from OpenDataSource (' microsoft.jet.oledb.4.0 ', ' + ' ' Data source= ' + M_str_pathname + ' "; User id=; password=; Extended properties=dbase 5.0 ") ... ' + m_str_filename; } {SELECT * to yourtablename from OPENROWSET (' msdasql.1 ', ' Driver=microsoft Excel driver (*.xls);D Bq=d:excelbook2.xls ' , ‘SELECT * FROM [sheet1$] ')} m_strsql: = ' select * to ' + M_str_filename + ' from ' + ' OPENROWSET (' msdasql.1 ', ' Driver =microsoft Excel Driver (*.xls);D bq= ' + m_str_pathname + m_str_filename + '. xls ', ' + ' select * from [sheet1$] '; {m_strsql1: = ' SELECT * to Book2 from ' + ' OPENROWSET (' msdasql.1 ', ' Driver=microsoft Excel driver (*.xls);D Bq=d:exce Lbook2.xls ', ' + ' select * from [sheet1$] '; } try M_adoconnection.execute (M_strsql); Except ShowMessage (m_str_filename + ') error on the table! ‘); Result: = false; Exit end; If P_progressbar <> nil then begin p_progressbar.position: = M_integer_itempos; End End

Result: = true; End

Function tform1.boolean_dbf_to_sqlserver_usingstringlist (p_str_machinename:string;//Machine name P_str_databasename: String; Database name p_str_username:string; User name p_str_password:string; User password p_stringlist_filenameandpath:tstringlist; File name and path list P_progressbar:tprogressbar//progress bar): Boolean; True: Operation succeeded Var//false: Operation failed m_adoconnection:tadoconnection; m_str_filenameandpath:string; m_str_filename:string; m_str_pathname:string; m_strsql:string; M_integer_itempos:integer; Begin M_adoconnection: = Tadoconnection.create (nil); M_adoconnection.connectionstring: = ' provider=sqloledb.1; ' + ' password= ' + P_str_password + '; ' + ' Persist Security info=t Rue; ' + ' User id= ' + p_str_username + '; ' + ' Initial catalog= ' + p_str_databasename + '; ' + ' Data source= ' + p_str_machine Name; M_adoconnection.loginprompt: = false; Try//Connect database server m_adoconnection.connected: = true; Except ShowMessage (' Boolean_dbf_to_sqlserver ():: Database connection Error! ‘); Result: = false; Exit; End;

If P_progressbar <> nil then begin p_progressbar.min: = 0; P_progressbar.max: = P_stringlist_filenameandpath.count; End For m_integer_itempos: = 1 to P_stringlist_filenameandpath.count do begin m_str_filenameandpath: = P_stringlist_ FILENAMEANDPATH.STRINGS[M_INTEGER_ITEMPOS-1]; M_str_filename: = Self.string_getfilenamefromonefullfilescript (M_str_filenameandpath); M_str_filename: = Self.string_deleteextnameforonefilename (M_str_filename); M_str_pathname: = Self.string_getfilepathfromonefullfilescript (M_str_filenameandpath); M_strsql: = ' drop table ' + m_str_filename; Try//delete the corresponding original table (if any) in SQL Server M_adoconnection.execute (M_STRSQL); except end; M_strsql: = ' SELECT * to ' + M_str_filename + ' from OpenDataSource (' microsoft.jet.oledb.4.0 ', ' + ' ' Data source= ' + M_str_pathname + ' "; User id=; password=; Extended properties=dbase 5.0 ") ... ' + m_str_filename; Try M_adoconnection.execute (m_strsql); Except ShowMessage (m_str_filename + ') error on the table! ‘); Result: = false; Exit end; If P_progreSsbar <> Nil THEN begin p_progressbar.position: = M_integer_itempos; End End

Result: = true; End

Resolve the "You are trying to execute CGI, ISAPI, or other executable program from the directory ..." I am debugging a Web page in the lab today, using WIN2003 Internet Information Services (IIS) Manager to create a Web site virtual directory, resulting in an error while browsing the Web page, The error message is as follows:---------------------------------------------------------

The page cannot be displayed

You attempted to execute a CGI, ISAPI, or other executable program from the directory, but the directory does not allow the execution of the program.

--------------------------------------------------------------------------------

Please try the following:

If you think the directory should allow access, contact the site administrator. HTTP Error 403.1-Forbidden access: execution access denied. Internet Information Services (IIS)

--------------------------------------------------------------------------------

Technical information (provided for technical support staff)

Go to Microsoft Product Support services and search for titles that include "HTTP" and "403." Open IIS Help (accessible in IIS Manager (inetmgr)), and then search for topics titled Configure ISAPI Extensions, configure CGI applications, protect sites with site permissions, and about custom error messages. In the IIS Software Development Kit (SDK) or MSDN Online Library, search for the title "Developing ISAPI Extensions", "ISAPI and CGI", and "debugging ISAPI Extensions and Filters "theme. -------------------------------------------------------------------------------------------------------

After commissioning, found that the solution is actually very simple. The solution is as follows:

Click the start of the operating system--programs--Administrative Tools--interneter Server management, select your site in IIS and then right--properties, in the Home directory option, to see if execute permissions are set to None, this is changed to "script only" save.

This article from Csdn Blog, reproduced please indicate the source: http://blog.csdn.net/lanmao100/archive/2009/03/18/4000010.aspx

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.