Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Other Programming > VBScript
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
VBScript For questions and discussions related to VBScript.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the VBScript section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old February 6th, 2005, 12:27 PM
vc1 vc1 is offline
Registered User
 
Join Date: Feb 2005
Location: , , .
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default Accessing sql server database trough vbs file

Can anyone please send me some sample code for accessing sqlserver database through a vbs file.

Thanks,
vineet


Reply With Quote
  #2 (permalink)  
Old February 6th, 2005, 01:21 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: High Wycombe, UK, United Kingdom.
Posts: 344
Thanks: 0
Thanked 1 Time in 1 Post
Default

Take a look at ISQL (http://msdn.microsoft.com/library/de..._isql_8r39.asp) I've used it on several projects to do the same thing.
Reply With Quote
  #3 (permalink)  
Old February 7th, 2005, 02:33 PM
vc1 vc1 is offline
Registered User
 
Join Date: Feb 2005
Location: , , .
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Please send me some sample code which is easy to understand as I am new to this technology.

Thanks for your help.

Reply With Quote
  #4 (permalink)  
Old February 14th, 2005, 09:13 AM
Friend of Wrox
Points: 9,611, Level: 42
Points: 9,611, Level: 42 Points: 9,611, Level: 42 Points: 9,611, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2004
Location: Washington, DC, USA.
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

What do you mean by "accessing" a SQL server? What do you want to do there?

Do you want to use a DSN, or ADO?

I use these connections to write data to SQL server. This may get you started if that is what you need:

'==========
strUserName = "yourSQLusername"
strPassword = "yourSQLpassword"
Const adOpenStatic = 3
Const adLockOptimistic = 3
Const adUseClient = 3

Set objConnection = CreateObject("ADODB.Connection")
Set objRecordset = CreateObject("ADODB.Recordset")
objConnection.Open "DSN=YourDSNName;", strUserName, strPassword
objRecordset.CursorLocation = adUseClient
objRecordset.Open "SELECT * FROM tblYourTable" , objConnection, adOpenStatic, adLockOptimistic

   objRecordset.AddNew
   objRecordset("Field1") = "YourData1"
   objRecordset("Field2") = "YourData2"
   '...
   objRecordset("Fieldn") = "YourDatan"
   objRecordset.Update

objRecordset.Close
objConnection.Close
'==========

HTH

mmcdonal
Reply With Quote
  #5 (permalink)  
Old February 14th, 2005, 09:14 AM
Friend of Wrox
Points: 9,611, Level: 42
Points: 9,611, Level: 42 Points: 9,611, Level: 42 Points: 9,611, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2004
Location: Washington, DC, USA.
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

BTW, this adds one new record to "tblYourTable" in a SQL server named "YourDSNName."

mmcdonal
Reply With Quote
  #6 (permalink)  
Old February 14th, 2005, 09:16 AM
Friend of Wrox
Points: 9,611, Level: 42
Points: 9,611, Level: 42 Points: 9,611, Level: 42 Points: 9,611, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2004
Location: Washington, DC, USA.
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

Sorry, with an account name of "yourSQLusername" with write access to tblYourTable", using SQL login, and a password of "yourSQLpassword."


mmcdonal
Reply With Quote
  #7 (permalink)  
Old February 18th, 2005, 09:54 AM
vc1 vc1 is offline
Registered User
 
Join Date: Feb 2005
Location: , , .
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks,By accessing SQL server I mean querying the database or doing some inserts and updates.

Your code helped me.

Reply With Quote
Reply


Thread Tools
Display Modes

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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
how to insert text file in sql server database sharvari_mothe Java Databases 3 June 5th, 2007 08:25 AM
how to store file in sql server 2000 database vivekkumar_23 SQL Server 2000 1 February 27th, 2006 10:41 PM
Upload a file to sql server database thas123 ASP.NET 1.0 and 1.1 Professional 3 January 9th, 2006 12:29 AM
Searching trough a database toni_montana PHP How-To 2 September 25th, 2004 10:17 AM
Emailing File from SQL Server Database hugh@kmcnetwork.com VB How-To 0 July 24th, 2004 10:06 AM



All times are GMT -4. The time now is 09:09 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.