Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Assinging values from SQL statement to variable

Status
Not open for further replies.

raljex

Technical User
Mar 12, 2001
3
GB
hi,

I have established a connection to a database and have assigned the record source to a SQL statement. How do i assign a variable the results of query?

raljex
 
Hello raljex

If I could understand the requirement correctly, following is the answer.
ADO recordset has a method called GetString() that should return your results as string:

Dim strResult as String
strResult = Adodc1.Recordset.GetString(adClipString, 15,";")
MsgBox strResult

Above, adClipString must be specified to confirm that the return type is of string. 15 is the number of rows to return and semicolon is column seperator, default is a tab. Also Adodc1 is the ADO data control with data already populated. I hope this would be of some help.

Regards

Irfan Ahmed
 
Thanks Irfan,

Have you any idea how to do this using a intrinsic Data control instead of using a ADO data control to the database?

Regards
Raljex
 
Work done now thanks Irfan.

I used Data.recordset.fields("fieldname") to access the data and place them into a variable.

Thanks anyway

Raljex
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top