Avatar billede kischi Novice
26. november 2008 - 23:00 Der er 44 kommentarer og
1 løsning

Fra Excel til MS Sql

Hej jeg prøver at gøre sådan så hvis der ligger en excel fil i en mappe på serveren, kan den hente data fra excel filen og ligge ned i Ms sql databasen.

Jeg har prøvet at læse mig lidt frem til det, men der står alt muligt om en ADO eller Oledb. Men jeg ved ikke hvad jeg skal bruge det til. Jeg håber der er nogle herinde som kan hjælpe mig?

Jeg ved godt hvordan man normalt forbinder til en Sql database og indsætter data og trækker ud. Men ikke fra en excel fil.

Så jeg vil være meget taknæmmelig hvis der er nogle som kan hjælpe mig med det.

Mvh. Adam Kischinovsky

På fårhånd tak. :-D
Avatar billede terry Ekspert
27. november 2008 - 08:27 #1
Avatar billede kischi Novice
27. november 2008 - 11:50 #2
Hej Tak for dit svar,
og undskyld at jeg ikke skrev mere precist, men jeg arbejder i c#
og i den artikel du linker til viser det i visual basic.

Har du et link til et sted som viser hvordan man gør i c#.

Mvh. Adam
Avatar billede terry Ekspert
27. november 2008 - 13:11 #3
I was thinking you could import useing DTS.

Anyway thi slink might help, hope so.
http://davidhayden.com/blog/dave/archive/2006/05/31/2976.aspx
mvh
Terry
Avatar billede kischi Novice
27. november 2008 - 19:21 #4
Ok jeg har prøvet det. Men når jeg tester siden kommer den bare med denne fejl:

The 'Microsoft
  .Jet.OLEDB.4.0' provider is not registered on the local machine.

Ved du hvordan jeg kan løse det?

Mvh. Adam
Avatar billede terry Ekspert
27. november 2008 - 19:55 #5
Hi Adam
You can start by looking at this link. Which OS do you use?

http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=125207&SiteID=1
Avatar billede kischi Novice
27. november 2008 - 20:10 #6
I'm using windows xp home edition version 2002 service pack 3

So I don't understand what I have to download so it will work, can you please help me with that?
Avatar billede terry Ekspert
27. november 2008 - 20:22 #7
If you look at the link I gave there is another link
http://support.microsoft.com/kb/278604

This is taken from that link. Follow the instruction, and hopefully it will work. If not we'll take it from there.

NOTE: This resolution uses a SQL Server OLE Provider DLL (Sqloledb.dll) as an example. Because the unregistered DLL may vary based on the OLE DB Provider that you are using, modify step 2 accordingly.

To resolve this problem, reregister the faulty DLL as follows:
At a command prompt, change to the C:\Program Files\Common Files\System\Ole DB folder.
At a command prompt, type the following command:
regsvr32 sqloledb.dll
You should receive confirmation that the DLL is registered successfully.
Avatar billede terry Ekspert
27. november 2008 - 20:32 #8
so you should have a file named
C:\Program Files\Common Files\System\Ole DB\sqloledb.dll
Avatar billede kischi Novice
27. november 2008 - 20:42 #9
Hi sorry for this question,
but how do I open the command prompt to type it in
Avatar billede terry Ekspert
27. november 2008 - 20:47 #10
Here's another method.

Press Start and then select Run, thats the English name, maybe its Køre.

Then copy this into the box
regsvr32 C:\Program Files\Common Files\System\Ole DB\sqloledb.dll
Avatar billede terry Ekspert
27. november 2008 - 20:57 #11
You can find a command prompt in programs + accessories.

I'm now closing my PC dowsn for the night, will take a look tomorrow
Avatar billede kischi Novice
27. november 2008 - 21:13 #12
Ok. thx for all the help for today. :-D

When I type: "regsvr32 sqloledb.dll" into the command prompt a windows error box appears and says:
LoadLibrary("sqloledb.dll")mislykkedes - Det angivne modul blev ikke fundet

I tried both ways, but I don't know why it says that?
Avatar billede terry Ekspert
28. november 2008 - 14:17 #13
Have you included the FULL path to the file?
"C:\Program Files\Common Files\System\Ole DB\..."

You could also try browsing to the folder to see if exists and if not we need to find out why it doesnt?

Do yo have SQL server installed on your PC as I would have thought that that would install it.
Avatar billede kischi Novice
28. november 2008 - 14:30 #14
I tried searching for the file on the computer, but I couldn't find it. so I don't think the file is on the computer.

And yes I have microsoft sql server installed on my computer.

So I think we need to find out how I get the file right?
Avatar billede terry Ekspert
28. november 2008 - 17:42 #15
sqloledb.dll is normally included with MDAC (Microsoft Data Access Components) which is normally included with Windows Xp and also SQL Server, so I find it strang ethat it isnt included on your PC. Anyway you should try downloading MDAC and installing it, but first it might be an idea to check the version you have insatlled, if any.

Here you can download a tool which will do that.
http://support.microsoft.com/kb/307255/
Avatar billede kischi Novice
29. november 2008 - 00:53 #16
Ok now I have downloadet a componentChecker from the link you gave me.
But I don't know how to check witch version of MDAC I am using.

Is that what you wan't me to do? Sorry, I don't really understand what you mean?

Mvh. Adam
Avatar billede terry Ekspert
29. november 2008 - 11:21 #17
Hi Adam
After you have downloaded the file (cc_pkg.exe) you have to double click on it to install the files to your PC and run the program.

Then you can do one of three things as described in the link given earlier.

1: Perform an analysis of your machine and automatically determine the release version.
2: Perform an analysis against a selected version.
3: Scan the machine. Don't perform an analysis.

So if you start with the first you will see which version you have on your PC.
You will also see a summery report with a list of all the files included in the MDAC version you have.
Normally you should have an MDAC version which includes the file you are missing (sqloledb.dll) and I'm sure this check will also confirm that the MDAC version you have is either installed incorrectly or is a version which doesnt included the file.

So if you can start with th efirst selection (Perform an analysis of your machine ...) then we can take it from there.
Avatar billede kischi Novice
29. november 2008 - 11:37 #18
Ok so I started with the first one. Then a popup comes where it says:

"The following product releases were matched:

UNKNOWN

would you like to re-run the query for a spicific product release?

yes  no. "

so I pressed no. and then the list came. and you are right there is a file their called sqloledb.dll

So what do I do now?
Avatar billede terry Ekspert
29. november 2008 - 11:47 #19
It sound to me as though you dont have any version of MDAC on your PC, or something has gone wrong under installation.

So I think you should try installing MDAC 2.8.

http://www.microsoft.com/downloads/details.aspx?FamilyID=6c050fe3-c795-4b7d-b037-185d0506396c&displaylang=en
Avatar billede kischi Novice
30. november 2008 - 11:14 #20
When I have downloadet it and try to install it.
A popup comes up and says:
MDAC 2.8 RTM er ikke kompatibel med denne version af Windows. Alle funktionerne er i øjeblikket en del af Windows

So I really don't know what's wrong. ?
Avatar billede terry Ekspert
30. november 2008 - 11:42 #21
I had an idea that that might happen. So we can try and older version (2.7)

http://www.microsoft.com/downloads/details.aspx?familyid=9ad000f2-cae7-493d-b0f3-ae36c570ade8&displaylang=en
Avatar billede terry Ekspert
30. november 2008 - 11:51 #22
Before you try 2.7, if you agin try 2.8 and then Press "Annuller" when you get the error, does the installatin continue?
Avatar billede terry Ekspert
30. november 2008 - 12:03 #23
as you can see from this link http://support.microsoft.com/kb/899861 it looks as though MDAC 2.81 are included with Windows XP SP2 and installing 2.8 will fail.

So try Method 1: Install MDAC 2.8 SP1
Avatar billede kischi Novice
30. november 2008 - 15:12 #24
When I press Anuller it dousn't contue installing.

Now I downloadet: Microsoft Data Access Components (MDAC) 2.8 SP1

so when I click on it a popup comes up and says:
This setup dous not suport installing on this operating system.

?
Avatar billede terry Ekspert
30. november 2008 - 17:01 #25
Next step is to try the next method mentioned in the last link given.

Method 2: Repair the MDAC 2.81 installation that is included with Windows XP SP2
Avatar billede kischi Novice
30. november 2008 - 17:35 #26
Ok it started doing what it should when I browsedto the folder:
C:\WINDOWS\ServicePackFiles\i386

But suddenly it stopped and now it is looking for a file called: handler.reg

Do you know where I can find that file?
Avatar billede terry Ekspert
30. november 2008 - 17:45 #27
Here is another link on how to repair MDAC.
http://www.macropool.com/en/download/mdac_xp_sp2.html


If you reda this you can see where the handler.reg file is.

>>>
c.  When prompted for the file handler.reg, either point to C:\Program Files\Common Files\System\msadc, or put the Windows XP CD in your CD-ROM drive.
Avatar billede kischi Novice
30. november 2008 - 21:34 #28
Ok now it continued, and I have the cd in the computer.
But now it is looking for: msado.tlb

Do you know where that is?
Avatar billede kischi Novice
30. november 2008 - 22:22 #29
now a popup is saying:

instalationsprogrammet kan ikke kopiere filen msado27.tlb

?
Avatar billede terry Ekspert
01. december 2008 - 18:03 #30
Not sure why it needs msado27.tlb, I would have thought it was 28 it wanted.
If you have followed the instructions for repairing correctly then I'm out of ideas.

You could try the MDAC repair tool you can find at the bottom of the page on the link I gave http://www.macropool.com/en/download/mdac_xp_sp2.html

And maybe you could also try and repair (if its possible) you Windows.
Avatar billede kischi Novice
01. december 2008 - 18:15 #31
ok, now it continued copying some files.
But when i press on the "MDAC_TYP.EXE" now it still pops up and says:
"This setup does not suport installing on this operating system."

If you are still out of ideas with this, do you then know if maybe there are other ways to copy data from excel to ms sql database?
that was how it all started. :-D
Avatar billede terry Ekspert
01. december 2008 - 18:20 #32
"But when i press on the "MDAC_TYP.EXE"?
Why do you need to do that, isnt the repair complete?
Avatar billede terry Ekspert
01. december 2008 - 18:21 #33
What version of SQL server do you have?
Avatar billede kischi Novice
01. december 2008 - 18:32 #34
Don't I have to press on the file that I downloaded before I tried to repair, to install it? And how can I check if the repair is complete and it is successful?
Would it just work now, to import excel to sql?

I have sql server 2005.

But I also have something called sql server 2008, but that is just with a configuration tool, that I can't use I think.

But the program I've been using is called visual webdeveloper 2008 express edition. So I have just been using the program's sql server. Until it is going on the net.

Do you understand what I mean?
Avatar billede terry Ekspert
01. december 2008 - 18:41 #35
I'm not at all usre what you have or have not done!

You downloaded the Component checker previoulsy from this link http://support.microsoft.com/kb/307255/

It is now installed on your PC, try runing the program again.
Avatar billede terry Ekspert
01. december 2008 - 18:45 #36
http://support.microsoft.com/kb/321686

Show how you can use DTS or Microsoft SQL Server 2005 Integration Services (SSIS)

Other than that, if you cant get your MDAC working then I cant help, sorry
Avatar billede kischi Novice
01. december 2008 - 22:40 #37
I can open the component checker and then I run the first option:
1: Perform an analysis of your machine and automatically determine the release version.

Then some files come, and there is also a file called: sqloledb.dll

could I use that for something. Or could you please explain how I can check if my MDAC is working?

Thanks

Adam
Avatar billede terry Ekspert
01. december 2008 - 23:04 #38
And does it also tell you which version of MDAC you have?

You can check if MDAC is working by trying out th ecode which produced the error you gave

27/11-2008 19:21:37
Avatar billede kischi Novice
01. december 2008 - 23:22 #39
No the message in the popup box is still:

"The following product releases were matched:

UNKNOWN

would you like to re-run the query for a spicific product release?

yes  no."

And when I try to run the page where it is supposed to tranfer data from the excel into the ms sql the error message is:

The 'Microsoft
  .Jet.OLEDB.4.0' provider is not registered on the local machine.

Does that meen that my mdac still doesn't work?
Avatar billede terry Ekspert
02. december 2008 - 08:10 #40
Yes I'm sorry to say it does mean your MDAC doesnt work.

Have you tried any of the other methods mentioned in the link given previously for importing Excel?

If you have tried and completed the repair and it still doesnt work then I'm out of ideas other than re-installing Windows.
Avatar billede kischi Novice
02. december 2008 - 11:02 #41
Ok I think I will try the first link you gave me.
Or will I also need an mdac for that?

And I don't really understand it, that's why did the other one instead.
There are more methods in that link I think, but witch one should I use?

Adam
Avatar billede kischi Novice
02. december 2008 - 11:12 #42
Now I actually tried downloading mdac 2.7 service pack 1

and it downloadet and installed succesfully. Do you think it will be possible to work with that?
Avatar billede kischi Novice
02. december 2008 - 11:25 #43
Hi again, now I actually maybe think the mistake is corrected, because before this line: @"Provider=Microsoft.Jet.OLEDB.4.0; was in 2 lines so I moved it up so it would be in one line, but now a new error came. I don't know if it meens the same, or how to fix this one. Now it says:
Den installerbare ISAM kan ikke findes.

Do you know what this meens?
Avatar billede terry Ekspert
02. december 2008 - 12:25 #44
In the first link there are a number of methods to import Excel into SQL Server.

I would have tried using DTS (SQL 2000) or Microsoft SQL Server 2005 Integration Services (SSIS) myself and I'm not sure if mdac is needed to do this,but thats easy enough to find out (try) :o)

"Now I actually tried downloading mdac 2.7 service pack 1"

And now I'm lost!
2.81 is included with Windows XP SP2 so I wouldnt have thought that you would be allowed to install 2.7.
Avatar billede terry Ekspert
02. december 2008 - 12:39 #45
"Den installerbare ISAM kan ikke findes."

I think it would be best for you to search on Google. If you try in English I think you have a better chance of finding something.

Try search on Google with

installable ISAM cannot be found XP
Avatar billede Ny bruger Nybegynder

Din løsning...

Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.

Loading billede Opret Preview
Kategori
Computerworld tilbyder specialiserede kurser i database-management

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester