- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Microsoft
- >
- Problem with connectivity of Ms SQL through VBScri...
Operating System - Microsoft
1820475
Members
3314
Online
109624
Solutions
Forums
Categories
Company
Local Language
юдл
back
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Discussions
Forums
Forums
Discussions
юдл
back
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Go to solution
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-18-2006 06:58 PM
тАО07-18-2006 06:58 PM
Hi
I want to connect the SQL through VBScript. But it is not working. And I am not able to fine where is the problem.
So if anyone understand the problem, please suggest me what should I change, or what is going wrong.
The VBScript I am using:
' Initialize variables
Dim cn
Dim ServerName
Dim DatabaseName
Set cn = CreateObject("ADODB.Connection")
' Put text box values into connection variables.
ServerName = "pfabwsus.dlh.st.com"
DatabaseName = "NITIN"
WSCript.Echo "Test 1"
' *******************************************************
' Specify the OLE DB provider.
cn.Provider = "SQLOLEDB"
' Set SQLOLEDB connection properties.
cn.Properties("Data Source").Value = ServerName
cn.Properties("Initial Catalog").Value = DatabaseName
' Windows NT authentication.
cn.Properties("Integrated Security").Value = "SSPI"
'********************************************************
'WScipt.Echo cn.Properties("ConnectionTimeout")
WScript.Echo "Connection Properties are set."
' Open the database.
cn.Open
WScript.Echo "Connection Established."
cn.Close
cn.Connection = Nothing
The same thing I am writing in the attachment.
Thanks and Regards
Nitin Kumar Gupta
I want to connect the SQL through VBScript. But it is not working. And I am not able to fine where is the problem.
So if anyone understand the problem, please suggest me what should I change, or what is going wrong.
The VBScript I am using:
' Initialize variables
Dim cn
Dim ServerName
Dim DatabaseName
Set cn = CreateObject("ADODB.Connection")
' Put text box values into connection variables.
ServerName = "pfabwsus.dlh.st.com"
DatabaseName = "NITIN"
WSCript.Echo "Test 1"
' *******************************************************
' Specify the OLE DB provider.
cn.Provider = "SQLOLEDB"
' Set SQLOLEDB connection properties.
cn.Properties("Data Source").Value = ServerName
cn.Properties("Initial Catalog").Value = DatabaseName
' Windows NT authentication.
cn.Properties("Integrated Security").Value = "SSPI"
'********************************************************
'WScipt.Echo cn.Properties("ConnectionTimeout")
WScript.Echo "Connection Properties are set."
' Open the database.
cn.Open
WScript.Echo "Connection Established."
cn.Close
cn.Connection = Nothing
The same thing I am writing in the attachment.
Thanks and Regards
Nitin Kumar Gupta
Solved! Go to Solution.
2 REPLIES 2
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-18-2006 08:21 PM
тАО07-18-2006 08:21 PM
Re: Problem with connectivity of Ms SQL through VBScript
Hello Nitin,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-18-2006 08:35 PM
тАО07-18-2006 08:35 PM
Solution
Hi again
This weblink would be of much help .. Check this out :
http://www.databasejournal.com/features/mssql/article.php/2238221
You can also try this chunk of code :
sql="SELECT * FROM UserLogs"
Set Connection = CreateObject("ADODB.Connection")
Connection.Open
(" Provider=sqloledb;server=MyMSSQLServerNa
me;database=NameOfDatabaseIUsed;uid=SQLU
serName;pwd=SQLUserPWD;")
Set RS = CreateObject("ADODB.RecordSet")
RS.ActiveConnection = Connection
RS.Open(sql)
Do While Not RS.BOF And Not RS.EOF
WScript.Echo(RS(1))
RS.MoveNext
Loop
RS.Close
Set RS = Nothing
Connection.Close
Set Connection = Nothing
-- code ends --
word wrapping might occur for Set Connection and Connection.Open statements.
If you have trouble authenticating with domain credentials, create a
SQL user and passed those credentials. Everything will work fine.
For more help on VBScript, you can find the attachment in my previous post.
Cheers,
Soujanya.R
This weblink would be of much help .. Check this out :
http://www.databasejournal.com/features/mssql/article.php/2238221
You can also try this chunk of code :
sql="SELECT * FROM UserLogs"
Set Connection = CreateObject("ADODB.Connection")
Connection.Open
(" Provider=sqloledb;server=MyMSSQLServerNa
me;database=NameOfDatabaseIUsed;uid=SQLU
serName;pwd=SQLUserPWD;")
Set RS = CreateObject("ADODB.RecordSet")
RS.ActiveConnection = Connection
RS.Open(sql)
Do While Not RS.BOF And Not RS.EOF
WScript.Echo(RS(1))
RS.MoveNext
Loop
RS.Close
Set RS = Nothing
Connection.Close
Set Connection = Nothing
-- code ends --
word wrapping might occur for Set Connection and Connection.Open statements.
If you have trouble authenticating with domain credentials, create a
SQL user and passed those credentials. Everything will work fine.
For more help on VBScript, you can find the attachment in my previous post.
Cheers,
Soujanya.R
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
Company
Learn About
News and Events
Support
© Copyright 2025 Hewlett Packard Enterprise Development LP