Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old October 21st, 2003, 01:09 AM
kentwlan kentwlan is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Posts: 4 kentwlan User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Write to SQL via vbscript

Can anyone give me the code to write to a SQL table from a vbscript. I have a script running on all my PC's which write to a flat file which I then import. Can I just run the script and have it write directly to SQL.

Reply With Quote
  #2  
Old October 21st, 2003, 01:16 AM
Scorpions4ever's Avatar
Scorpions4ever Scorpions4ever is offline
Banned ;)
Dev Shed God 6th Plane (7500 - 7999 posts)
 
Join Date: Nov 2001
Location: Glendale, Los Angeles County, California, USA
Posts: 7,589 Scorpions4ever User rank is General (90000 - 100000 Reputation Level)Scorpions4ever User rank is General (90000 - 100000 Reputation Level)Scorpions4ever User rank is General (90000 - 100000 Reputation Level)Scorpions4ever User rank is General (90000 - 100000 Reputation Level)Scorpions4ever User rank is General (90000 - 100000 Reputation Level)Scorpions4ever User rank is General (90000 - 100000 Reputation Level)Scorpions4ever User rank is General (90000 - 100000 Reputation Level)Scorpions4ever User rank is General (90000 - 100000 Reputation Level)Scorpions4ever User rank is General (90000 - 100000 Reputation Level)Scorpions4ever User rank is General (90000 - 100000 Reputation Level)Scorpions4ever User rank is General (90000 - 100000 Reputation Level)Scorpions4ever User rank is General (90000 - 100000 Reputation Level)Scorpions4ever User rank is General (90000 - 100000 Reputation Level)Scorpions4ever User rank is General (90000 - 100000 Reputation Level)Scorpions4ever User rank is General (90000 - 100000 Reputation Level)Scorpions4ever User rank is General (90000 - 100000 Reputation Level) 
Time spent in forums: 1 Month 1 Day 22 h 58 m 25 sec
Reputation Power: 1001
What SQL engine are we talking about here? Access, SQL Server, MySQL, Oracle or what? Also, it would help if you specified what you are writing to the text files currently.
__________________
Up the Irons
What Would Jimi Do? Smash amps. Burn guitar. Take the groupies home.
"Death Before Dishonour, my Friends!!" - Bruce D ickinson, Iron Maiden Aug 20, 2005 @ OzzFest
Down with Sharon Osbourne

Puzzle of the Month solved by Keath and KevinADC, superior perl programmers of the month
Looking for a perl job with kick-*** programmers in a well-known NASDAQ listed tech company with branches in the US and Europe? We're hiring. PM me for details. Requirements

Reply With Quote
  #3  
Old October 21st, 2003, 04:16 AM
cleverpig cleverpig is offline
Contributing User
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Jul 2003
Posts: 1,152 cleverpig User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 7
Send a message via MSN to cleverpig
U can modify a asp file realize this function to vbs file..

Reply With Quote
  #4  
Old November 26th, 2003, 02:15 PM
ghort ghort is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2003
Location: HK, CZE
Posts: 3 ghort User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Hi!

Here os the code I use for writing data into DB (it calls stored procedure for checking inserted data, hope it will be usefull for you)

<code>
Function LogResultSQL (strSQLServer, strDBName, strProcName, strUser, strPassword, strScriptName, strCompName, dtDateTime, strEventID, strEventDesc, strEventExecCommand, numEventResult)
'
' Call stored procedure strProcName stored in database strDBName on SQL Server strSQLServer, authenticating as user strUser with password strPassword
' Insert parameters for strProcName are: strScriptname, strCompName, dtDateTime, strEventID, strEventDesc, strEventExecCommand a numEventResult
' Function returns the return code of that stored procedure
'

Dim objConnection
Dim objCmd
Dim objParams

Dim numReturnValue

Set objConnection = CreateObject("ADODB.Connection")
objConnection.Open "Provider=sqloledb;Data Source=" & strSQLServer & ";Initial Catalog=" & strDBNAme & ";User Id=" & strUser & ";Password=" & strPassword & ";"


Set objCmd = CreateObject("ADODB.Command")
Set objCmd.ActiveConnection = objConnection
objCmd.CommandText = strProcName
objCmd.CommandType = 4

Set objParams = CreateObject("ADODB.Parameter")
objParams.Type = 3 ' adInteger
objParams.Direction = 4 'adParamReturnValue
objCmd.Parameters.Append objParams

Set objParams = CreateObject("ADODB.Parameter")
objParams.Type = 200 ' adVarChar
objParams.Size = 50
objParams.Direction = 1 'adParamInput
objParams.Value = strCompName
objCmd.Parameters.Append objParams

Set objParams = CreateObject("ADODB.Parameter")
objParams.Type = 135 ' adDBTimeStamp
objParams.Direction = 1 'adParamInput
objParams.Value = dtDateTime
objCmd.Parameters.Append objParams

Set objParams = CreateObject("ADODB.Parameter")
objParams.Type = 200 ' adVarChar
objParams.Size = 1000
objParams.Direction = 1 'adParamInput
objParams.Value = strEventID
objCmd.Parameters.Append objParams

Set objParams = CreateObject("ADODB.Parameter")
objParams.Type = 200 ' adVarChar
objParams.Size = 4000
objParams.Direction = 1 'adParamInput
objParams.Value = strEventDesc
objCmd.Parameters.Append objParams

Set objParams = CreateObject("ADODB.Parameter")
objParams.Type = 200 ' adVarChar
objParams.Size = 1000
objParams.Direction = 1 'adParamInput
objParams.Value = strEventExecCommand
objCmd.Parameters.Append objParams

Set objParams = CreateObject("ADODB.Parameter")
objParams.Type = 3 ' adInteger
objParams.Direction = 1 'adParamInput
objParams.Value = numEventResult
objCmd.Parameters.Append objParams

Set objParams = CreateObject("ADODB.Parameter")
objParams.Type = 200 ' adVarChar
objParams.Size = 1000
objParams.Direction = 1 'adParamInput
objParams.Value = strScriptName
objCmd.Parameters.Append objParams

objCmd.Execute

'Set objParams = objCmd.Parameters.Item(0)
Set objParams = objCmd.Parameters(0)
numReturnValue = objParams.Value

Set objConnection = Nothing
Set objCmd = Nothing
Set objParams = Nothing

LogResultSQL = numReturnValue

end Function ' LogResultSQL (strSQLServer, strDBName, strProcName, strUser, strPassword, strCompName, dtDateTime, strEventID, strEventDesc, strEventExecCommand, numEventResult)
</code>

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming > Write to SQL via vbscript


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway
Stay green...Green IT