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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Change Data Field name in Data Grid

Status
Not open for further replies.

hkung

Programmer
Jan 9, 2001
19
0
0
MY
Hi all,

I have an ADODC control, namely Adodc1, having the sql statement as below :

sqlstr = "select to_char(IN_DATETIME,'dd-mm-yyyy hh24:mi:ss'),
, other_field from table1"

and the Adodc1 is bind to DataGrid1.
Upon clicking the IN_DATETIME column header, i wish to sort the recordset by IN_DATETIME. I use the following codes in the DataGrid1_HeadClick(ByVal ColIndex As Integer) function:
***************************************************************
strColName = DataGrid1.Columns(ColIndex).DataField
Adodc1.Recordset.Sort = strColName & " DESC"
***************************************************************

However, it gave me error as below whenever i click on the IN_DATETIME column :
****************************************************************
run-time error '3265': Ado could not find the object in the collection corresponding to the name or ordinal reference requested by the application.
****************************************************************

I believe it is because of the sql i used in Adodc1 as the data field name in Adodc1 is recognised as :
to_char(IN_DATETIME,'dd-mm-yyyy hh24:mi:ss')

Is there anyway i can set the ADODC recordset field name manually in the code? I tried :
Adodc.Recordset.Fields(ColIndex) = strColName

but it gave me the following error :
****************************************************************
run-time error '91':
Object variable or With block variable not set
***************************************************************
Due to some reasons, i must use to_char(IN_DATETIME,'dd-mm-yyyy hh24:mi:ss') in my sql instead of IN_DATETIME.

Can anyone give me some hints how should i go about it? Thanks in advance.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top