fallnwrld
March 5th, 2009, 11:02 AM
Imports System.Data.SqlClient
Dim SQLStr, ConnString As String
ConnString = "Data Source=Server;Initial Catalog=CDAD;Integrated Security=True"
Dim SQLConn As New SqlConnection() 'The SQL Connection
Dim SQLCmd As New SqlCommand() 'The SQL Command
Dim SQLdr As SqlDataReader 'The Local Data Store
SQLConn.ConnectionString = ConnString 'Set the Connection String
SQLStr = "SELECT COUNT(*) FROM TABLE WHERE strComputerName = 'TomsCPU' AND strApplication = 'TomsApplication'"
SQLConn.Open() 'Open the connection
SQLCmd.Connection = SQLConn 'Sets the Connection to use with the SQL Command
SQLCmd.CommandText = SQLStr 'Sets the SQL String
SQLdr = SQLCmd.ExecuteReader 'Gets Data
Table Looks Like
TABLE
strComputerName
TomsCPU
GarysCPU
TomsCPU
strOffice
Florida
Texas
FLorida
strApplication
TomsApplication
ExcelX
TomsApplicationNow the count should return 2. How do I retrieve the count from the data reader.
Dim SQLStr, ConnString As String
ConnString = "Data Source=Server;Initial Catalog=CDAD;Integrated Security=True"
Dim SQLConn As New SqlConnection() 'The SQL Connection
Dim SQLCmd As New SqlCommand() 'The SQL Command
Dim SQLdr As SqlDataReader 'The Local Data Store
SQLConn.ConnectionString = ConnString 'Set the Connection String
SQLStr = "SELECT COUNT(*) FROM TABLE WHERE strComputerName = 'TomsCPU' AND strApplication = 'TomsApplication'"
SQLConn.Open() 'Open the connection
SQLCmd.Connection = SQLConn 'Sets the Connection to use with the SQL Command
SQLCmd.CommandText = SQLStr 'Sets the SQL String
SQLdr = SQLCmd.ExecuteReader 'Gets Data
Table Looks Like
TABLE
strComputerName
TomsCPU
GarysCPU
TomsCPU
strOffice
Florida
Texas
FLorida
strApplication
TomsApplication
ExcelX
TomsApplicationNow the count should return 2. How do I retrieve the count from the data reader.