Running Small Business Server 2003 premium fully patched. This server is running SQL Server 2000.
I have a DTS routine which uses vbscript.
I want to feed a field to a function and somehow construct a statement which will obtain the data from the desired field.
In the code listed below, the value customerID is obtained. My SELECT statement will find several fields:
Dim StrSqlCmd
Dim strFieldName
StrSqlCmd = SELECT customerID, CompanyName, ContactName, Contact _ &
FROM dbo.Customers
strFieldName = customerID
I will pass the sql command and the field I want to a function. In the example below, the field named customerID is hard coded. I need an example to show me how I would construct a statement to return the data from a field passed as a parameter.
set iRowCount = Flds("customerID") << this works fine
set iRowCount = Flds("strFieldName ") << This FAILS. How do I construct this so I can retrieve data from a field name in a variable?
============== Example =====================
dim myConn
dim myRecordset
dim iRowCount
' instantiate the ADO objects
set myConn = CreateObject("ADODB.Connec
tion")
set myRecordset = CreateObject("ADODB.Record
set")
' set the connection properties to point to the Northwind database,
' using the Customers table
myConn.Open = "Provider=SQLOLEDB.1;Data Source=(local); _
Initial Catalog=Northwind;user id = 'sa';password='sapassword'
"
StrSqlCmd = SELECT customerID, CompanyName, ContactName, Contact _ &
FROM dbo.Customers
myRecordset.Open StrSqlCmd, myConn
set Flds = myRecordset.Fields
set iRowCount = Flds("customerID")
Start Free Trial