to_char(Column_name) what would be the column name in dataset

3k views Asked by At

I have a column name as CREATEDATE. I use this sqlcommand to get the information

string sql = "SELECT USERID,USERNAME,USERPOSITION,UPDATEUSERID,USERSTATUS,TO_CHAR(CREATEDATE, 'DD-MM-YYYY HH24:MI:SS') FROM USERMASTER WHERE USERID ='" + stat[0] + "'";

I bind them in to dataset ds.

when I want to get the data of TO_CHAR(CREATEDATE, 'DD-MM-YYYY HH24:MI:SS')

I try to assign this way.

lblCreatedOn.Text = ds.Tables[0].Rows[0]["TO_CHAR(CREATEDATE, 'DD-MM-YYYY HH24:MI:SS')"].ToString();

its throw me an error call Column 'TO_CHAR(CREATEDATE, 'DD-MM-YYYY HH24:MI:SS')' does not belong to table Table.

anyone know what the column would be?

1

There are 1 answers

0
Lalit Kumar B On BEST ANSWER

Sometimes in few applications, the alias needs the keyword AS to qualify as an alias. Or, may be you need quoted identifier, i.e. use double-quotation marks.

So, modify it as:

TO_CHAR(CREATEDATE, 'DD-MM-YYYY HH24:MI:SS') AS "CREATEDATE"