Mit problem opstår, når jeg skal have indholdet ud i nogle variabler, som jeg kan smide i databasen!
Set tf = FSO.OpenTextFile("C:\2450.txt") Do While Not tf.AtEndOfStream theContent = theContent & tf.ReadLine Loop tf.Close theContent2 = Left(theContent, Len(theContent) - 1) splitItUp = Split(theContent2, ";") For Each x In splitItUp 'Her opstår mit problem! Next
Som sagt, så skal jeg bruge en funktion, der smider de respektive værdier ud i nogle variabler, som jeg så senere kan smide op i databasen!.. Hver linie i tekstfilen skal være et nyt insert statement i SQL-serveren hvori jeg har to values: Første separerede værdi og anden separerede værdi!
Hi Thomas> Are you talking about MS SQL Server? If your file looks like this bannerreklame24.mpg;18:56 02/03/2002; bannerreklame22.mpg;19:20 02/03/2002; bannerreklame16.mpg;12:56 02/03/2002; bannerreklame70.mpg;13:20 02/03/2002;
Then why cant you import it into SQL Server with DTS?
I haven't really thought about that. However, my problem is, that I need to be able to run this program every 5 minutes or so. Do you know if DTS can do that?
Okay!.. But there's another problem with this procedure that I just thought of. I don't know the name of the textfiles. There will be hundreds of them, and they need to be deleted one by one after the information has been stored in the DB. In VB I would be able to scan a specific folder for files ending with .txt and I don't know if this is possible in DTS!?
After a VERY quick look it would be possible to copy the file names ending in for example .txt into a file which you could then import into a table in your SQL dB then you could just loop through the table importing them one at a time. This is a part of whatI found:
E. Write variable contents out to file This example writes the contents of the current directory to a file named dir_out.txt in the current server directory.
DECLARE @cmd sysname, @var sysname
SET @var = 'dir /p'
SET @cmd = 'echo ' + @var + ' > dir_out.txt'
EXEC master..xp_cmdshell @cmd
There are more than likely other ways this could be done, tahts just one idea!
Where did you find this?.. I have been searching through books online, but I haven't been able to find anything. I have never worked with DTS before, so I need all the help I can get!..
I actually found the dir example by searching for dir in Books online. In SQL Server 2000 there are over 100 pages concerning DTS. Enter DTS Overview and then choose the DTS Overview topic from the list.
In SQL Server 7.0 Enter Overview of Data Transformation Services and againfind this in the topic list
Oh my.. There is a lot of reading to do. I think I'll stick with trying to code the Visual Basic App for now. This project has to be finished tomorrow morning, so I'm in a bit of a hurry!
I want to thank you for your very constructive help!! Although you didn't give me the exact solution, you have given me something else to work on in the future!!
If nobody else gives me a solution for this problem, I'll give the points to you!
thanks :o) You should take a look at DTS when you have time, it can do MUCH more than you could imagine.
terry
Synes godt om
Ny brugerNybegynder
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.