I am trying to populate textbox on winsows application from database.

The stored procedure pulls data using datareader. Data looks fine when I execute stored procedure on SQL server management studio.

But when I am trying to populate from the application its not getting same result.

I apprecaite all help.


txtovrts.Text = dr["lst_mod_dt"].ToString();
// returns date only

 txtovrts.Text = Convert.ToDateTime(ds["lst_mod_dt"].ToString("MM/dd/yyyy hh:mm:ss");
 //returns correct date but time stamp is always returned as 12:00:00(which is incorrect)

Recommended Answers

All 2 Replies

Is it possible that the actual datetime value in the database has 00:00:00.000 for the time portion? I tried this with my SQL database and it worked as you wanted. The first time I got 09/14/1994 00:00:00 and my database value was 09/14/1994 00:00:00.000. When I manually set the database value to 09/14/1994 09:17:23.000 then that was the value displayed when I ran the code.

Thansk for response. I have different values in the databse table, its just conversion part seems to be issue in my application. I also cecked executing stored procedure it returns same value as in the table for that particular coulmn.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.