bartvanbez
IS-IT--Management
Hello,
I have some problems for running SQL Statements that i have write bellow.
1. Connection to the database is correct. (i see session on server)
2. Is the RecordSet correct with the SELECT Query?
3. Is the script Wscript.Echo correct to return integer value?
I hope somebody can helping.
==========================================================
Dim mConnection
Dim mRecordset
Dim Data
Dim sql
'Create object RecordSet ADO
Set mRecordset = CreateObject("ADODB.Recordset")
'Create object Connection ADO
Set mConnection = CreateObject("ADODB.Connection")
'Connection with SQL Server 2005 Express W2K8DB01\SQLEXPRESS
mConnection.ConnectionString = "Provider=SQLOLEDB.1;Data Source=W2K8DB01\SQLEXPRESS;Initial Catalog=*****;User Id=sa;Password=*****;"
mConnection.Open
'Check connection with database: 0=false 1=true
'Connection must be display in SQL Management Sudio - Activity Monitor
'In SQL Management Sudio - Activity Monitor under Application you see Microsoft Windows Script Host.
'Session is display connection is oke!
MsgBox "1 = verbonden - waarde = " & mConnection.State
'Defineer SQL Query
sql = "SELECT * FROM incident where gereed = 0"
' Create a Recordset by executing an SQL statement.
mRecordset.Open
mConnection.open sql,mConnection
'Close connections
mRecordset.Close
mConnection.Close
' Display sum of total rows (integer) form query
WScript.echo mRecordset.Open & ":OK"
==========================================================
I have some problems for running SQL Statements that i have write bellow.
1. Connection to the database is correct. (i see session on server)
2. Is the RecordSet correct with the SELECT Query?
3. Is the script Wscript.Echo correct to return integer value?
I hope somebody can helping.
==========================================================
Dim mConnection
Dim mRecordset
Dim Data
Dim sql
'Create object RecordSet ADO
Set mRecordset = CreateObject("ADODB.Recordset")
'Create object Connection ADO
Set mConnection = CreateObject("ADODB.Connection")
'Connection with SQL Server 2005 Express W2K8DB01\SQLEXPRESS
mConnection.ConnectionString = "Provider=SQLOLEDB.1;Data Source=W2K8DB01\SQLEXPRESS;Initial Catalog=*****;User Id=sa;Password=*****;"
mConnection.Open
'Check connection with database: 0=false 1=true
'Connection must be display in SQL Management Sudio - Activity Monitor
'In SQL Management Sudio - Activity Monitor under Application you see Microsoft Windows Script Host.
'Session is display connection is oke!
MsgBox "1 = verbonden - waarde = " & mConnection.State
'Defineer SQL Query
sql = "SELECT * FROM incident where gereed = 0"
' Create a Recordset by executing an SQL statement.
mRecordset.Open
mConnection.open sql,mConnection
'Close connections
mRecordset.Close
mConnection.Close
' Display sum of total rows (integer) form query
WScript.echo mRecordset.Open & ":OK"
==========================================================