Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Windows Script to insert into SQLtable

Author  Topic 

Agent
Starting Member

2 Posts

Posted - 2004-10-14 : 05:56:55
Hi
I am trying to write a .vbs file that will retrive info from the computer filesystem object and then write that info directly into a sql table. The script is currently emailing me the results and I then copy them into the table
Any ideas on how to write a vb script to do this.

Thanks

Kristen
Test

22859 Posts

Posted - 2004-10-14 : 06:52:30
Open a database connection and INSERT the data into a table? Or am I missing the essence of what you need to do?

Kristen
Go to Top of Page

Agent
Starting Member

2 Posts

Posted - 2004-10-14 : 07:11:01
I don't know how to do it. I have only ever done it using ASP not windows scripting. Would you do it the same way?
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2004-10-14 : 09:24:57
Its pretty much identical, yes. There just isn't any RESPONSE.WRITE !

There are two flavours (from a rather shakey memory, so this won't be gospel!)

C> CSCRIPT MyScript.VBS
and
C> WSCRIPT MyScript.VBS

one just runs from the command line, outputing anythign to DOS. The other sparks up a Window, outputting to that instead. There is different syntax for each method for actually outputing text.

http://www.devguru.com/Technologies/wsh/quickref/wsh_intro.html
and
http://www.devguru.com/Technologies/vbscript/quickref/vbscript_intro.html

will probably give you some pointers

Ah ... here's a relevant bit:
quote:
An interesting aspect of WSH is that it contains two platform-specific executables, cscript.exe and wscript.exe. The echo (output) for cscript is to a command window (via a Win32 console application). While the echo (output) for wscript is to a graphical message box (via Windows). Just remember that the c stands for console and the w for Windows. For a full list of arguments, enter "cscript /?" or "wscript /?" at a command prompt.


Kristen
Go to Top of Page

Seventhnight
Master Smack Fu Yak Hacker

2878 Posts

Posted - 2004-10-14 : 09:37:10
what filesystem info are you looking for??

If it can be found using DOS commands?:

Create Table #dirOutPut (id int identity(1,1), diroutput varchar(1000))

Declare @dosStr varchar(1000)
Set @dosStr = 'dir c:\'

Insert Into #dirOutPut
Exec(@dosStr)

Select * from #dirOutPut

Drop Table #dirOutPut


Corey
Go to Top of Page

Lumbago
Norsk Yak Master

3271 Posts

Posted - 2004-10-14 : 17:35:07
Creating a .vbs-file is painstakingly easy. All you do is to create an asp-file that doesn print anything to the screen, make sure it works correctly, remove all <% and %> and all "Server" (i.e. Server.CreateObject("ADODB.Connection") => CreateObject("ADODB.Connection")) and save the file as .vbs. Works like a charm...

--
Lumbago
"Real programmers don't document, if it was hard to write it should be hard to understand"
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2004-10-15 : 00:57:43
And how enoying is the "remove all <% and %>" bit ... that means that we can't share include files between ASP and VBS </rant>

... or can we?

Kristen
Go to Top of Page

Lumbago
Norsk Yak Master

3271 Posts

Posted - 2004-10-15 : 04:00:05
Nope, that's not possible...at least not that I know of. ASP has the Server.Execute("file.asp") that is almost like an include but not sure if Execute("file.asp") will work in a .vbs. Worth a try though.

--
Lumbago
"Real programmers don't document, if it was hard to write it should be hard to understand"
Go to Top of Page
   

- Advertisement -