Wednesday, March 21, 2012
How to allow ExecQuery in VBScript Job Step?
VBScript Job Step? For example:
Set oDmoSqlServer=CreateObject("SQLDMO.SqlServer2")
With oDmoSqlServer
.LoginSecure=True
.Name="(local)"
.Connect
End With
sds_DbSrvName=oDmoSqlServer.HostName
Set oDb=oDmoSqlServer.Databases("SomeDatabase","dbo")
Set oWMIServer=GetObject("winmgmts://./root/cimv2")
strSQL="Select * from Win32_LogicalDisk WHERE DriveType=3"
Set colItems=oWMIServer.ExecQuery(strSQL,"WQL",48)
For Each oItem in colItems
With oItem
sds_cDeviceID=.DeviceID
sds_cFileSystem=.FileSystem
sds_cFreeSpace=.FreeSpace
sds_cSize=.Size
sds_cSystemName=.SystemName
sds_cVolumeName=.VolumeName
sds_cVolumeSerialNumber=.VolumeSerialNumber
End WithI neglected to mention: the applicable server and sql agent accounts have:
Act as part of the operating system
Bypass traverse checking
Increase quotas
Lock pages in memory
Logon as a batch job
Logon as a service
Replace a process level token
What is missing?
"Mongo" <nospam@.nospam.com> wrote in message
news:eJOoVbCUFHA.3312@.TK2MSFTNGP09.phx.gbl...
> What are the steps to authorize use of ExecQuery inside a MSSQL Server
> VBScript Job Step? For example:
> Set oDmoSqlServer=CreateObject("SQLDMO.SqlServer2")
> With oDmoSqlServer
> .LoginSecure=True
> .Name="(local)"
> .Connect
> End With
> sds_DbSrvName=oDmoSqlServer.HostName
> Set oDb=oDmoSqlServer.Databases("SomeDatabase","dbo")
> Set oWMIServer=GetObject("winmgmts://./root/cimv2")
> strSQL="Select * from Win32_LogicalDisk WHERE DriveType=3"
> Set colItems=oWMIServer.ExecQuery(strSQL,"WQL",48)
> For Each oItem in colItems
> With oItem
> sds_cDeviceID=.DeviceID
> sds_cFileSystem=.FileSystem
> sds_cFreeSpace=.FreeSpace
> sds_cSize=.Size
> sds_cSystemName=.SystemName
> sds_cVolumeName=.VolumeName
> sds_cVolumeSerialNumber=.VolumeSerialNumber
> End With
>|||Hi Mongo,
You may have try execute the script via xp_cmdshell instead of running it
from Job.
Sincerely yours,
Michael Cheng
Microsoft Online Partner Support
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
========================================
=============
This posting is provided "AS IS" with no warranties, and confers no rights.sql
Sunday, February 19, 2012
How to access to database with c# using DSN
Hello, im new in c# language.
Can someone show me, step by step(with simples code) how can i connect to a DSN connection that aconfigure in my odbc connection in my machine, to connect to mydatabase ?
I need only a simple class that use a DSN connection to retreive information from the database.
Best regards
You don't want to use a System DSN. A System DSN uses ODBC which is a wrapper for OLE DB, meaning that you're talking about a lot of unnecessary overhead. The .Net System.Data.SqlClient classes talk directly to the SQL Server, without having to use OLE DB OR ODBC. Instead, you need to figure out how to build your Connection correctly.
TryConnectionStrings.com.
|||Im not use SQL server, my database is db2 in AS/400.
Do u know how to connect directly to an as/400 database ?
|||Hi,
From you description, it seems that you want to connect to your DB2 database by using DSN, right?
I suggest that you can try DB2OdbcFileConnectionString class which describes a DB2 ODBC file connection string.
To create a DSN file and associated connection string
Call the constructor for DB2OdbcFileConnectionString, DB2OdbcSysConnectionString, or DB2OdbcUserConnectionString.
Calling the constructor creates a connection string with default settings. These default settings can be set only through the Data Access Tool user interface.
If you use a file path for a file that currently exists, the system loads the connection string information in that file instead.
Fill in the relevant connection string properties with a call to the properties of the object created.
You can also fill in the connection string with GetString, which returns the connection string as a text string. Once you finish modifying the relevant values, you can return the connection string to the object with a call to SetString.
Save the connection string information back into storage with a call to Save.
For more information, see:
http://msdn2.microsoft.com/en-us/library/ms945575.aspx
Thanks.