
October 14th, 2009, 12:35 PM
|
|
Registered User
|
|
Join Date: Oct 2009
Posts: 1
Time spent in forums: 35 m 15 sec
Reputation Power: 0
|
|
|
Assign database field to a variable SQL 2000
I am creating a comma delimited txt file and some of the fields I want need to come from a SQL 2000 database. I've found some code that seems to get me connected to the database, but I need to select a field and assign the value of the field to a variable so that I can write it to the file.
Code:
Const adOpenStatic = 3
Const adLockOptimistic = 3
Set objConnection = CreateObject("ADODB.Connection")
Set objRecordSet = CreateObject("ADODB.Recordset")
objConnection.Open _
"Provider=SQLOLEDB;Data Source=D6RZ4vc1;" & _
"Trusted_Connection=Yes;Initial Catalog=DATA;" & _
"User ID=sa;Password=sspqiv;"
objRecordSet.Open "SELECT col027 FROM arresfil_sql where col001 = '000000000002'", _
objConnection, adOpenStatic, adLockOptimistic
objRecordSet.MoveFirst
|