Link to home
Start Free TrialLog in
Avatar of dinesh_bali
dinesh_bali

asked on

Importing data from Excel in Database SQL2005

Hi,

I am working in C# and making Windows Application.

I have an excel file to which I want to import in the database SQL 2005

How can i do this, also I do not want to make dsn, but i can make file DSN

Can anyone help me in this regard

Thanks in Advance
Avatar of AGBrown
AGBrown
Flag of United Kingdom of Great Britain and Northern Ireland image

Would it be possible to use Integration Services to do this in your situation? It won't be as easy to do it on-demand, but you could schedule the SQl agent to run the SSIS job every minute, and get that job to pick up any spreadsheets sitting in a certain directory? It really depends on whether this is a local application, or a web application, and how SQL server is setup (and which version you are running).

A.
Avatar of dinesh_bali
dinesh_bali

ASKER

Ok, If you have the solution with DSN or some other,

that if user click on the button then the filtered data goes into sql 2005

Thanks in Advance
Is this a web application, or a windows application?
Avatar of Dmitry G
You can import excel file into SqlServer using SqlServer Enterprize Manager try following:

Select Tools tab.
In that select Data Transformation Services.
In that select import Data
Then you follow the wizard.

Hope this helps.

Another approach I used some time ago : I read data from Excel to DataSet, just need appropriate connection string
Then changed connection and saved into database. Can't remember details exactly but it worked well and was quite easy.
I want to do using C# code.

My excel format and database format is not same.

So I need to filter the data from C# SQL Query and then insert the data in the database.

Can you please help me in this context
ASKER CERTIFIED SOLUTION
Avatar of Dmitry G
Dmitry G
Flag of New Zealand image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
It is certainly possible, but there's all sorts of inherent problems with this. For one, Excel is a user application, so it might flash up "dialog boxes" in the "user space" of the account running your code. If your code is a web application, this can freeze your web application. Secondly, Jet is pretty bad at recognising data types. If the first 5 rows of data in one column look like numbers, but there is a text string somewhere in that column, it will cause errors.

So it really comes back to what the end-use of this is; server (web or other) application, or a user application? Is the SQL server a local install, or a centrally managed server?

A