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!

Setting ADODC RecordSource in code...

Status
Not open for further replies.

wrbodine

Programmer
Aug 24, 2000
302
US
Is there any way to set the CommandText (SQL) for the RecordSource property of an ADODC Control within code???

If not, is it possible to have a form variable as one of the parameters of the SQL Statement when you enter it in the ADODC's properties?

Thanks mucho,
Ray
 
Someone showed me the answer:

At run-time you can set the RecordSource to a new SQL statement:
ADODC1.RecordSource="new SQL text"

You might then have to call the Refresh method:
ADODC1.Refresh

(Make sure that at design time you set CommandType to adCmdText for the data
control).
 
You could try this code:

Form_Load()


ADODC1.ConnectionString = Provider SQOLEDB...
ADODC1.CommandType = acCmdText
ADODC1.RecordSource = "type your SQL Statement"
ADODC1.Refresh



 
Ray

Are you using the Data Environment to create you SQL comand and you want to change that at run time???

If so then use

DE1.Commands("inst").CommandText = "INSERT INTO `CLI` SELECT * FROM......."

where "inst" is the name of your SQL command in the data environment

If you are not using the DE then dont worry about this!!

DamoOz
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top