Click here to Skip to main content
15,890,438 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Saving the record into data base from data grid view.

code as follows;

C#
sql = "insert into Tb_SCh_TIme_Table(Date,Session,Course,Faculty_Code)" + " values ('" + Convert.ToDateTime(datagridView.Rows[i].Cells[0].Value.ToString()) + "', '" + int.Parse(datagridView.Rows[i].Cells[1].Value.ToString()) + "', '" + datagridView[j, i].Value.ToString() + "','" + datagridView.Columns[j].HeaderText.ToString() + "')";

through the above query it is saving to the data base.

in database Date is stored in the format such as 1/7/2013 12:00:00 AM.

but i want the the date to be stored in the format of 1 jan only.

the above format of date and month(Month to be character format)

Convert.ToDateTime(datagridView.Rows[i].Cells[0].Value.ToString()

from the above query how to do.

output as follows;

Date
1 jan
8 jan
3 Feb

like that to be saved in the data base.

how to do.please help me.
Posted
Updated 14-Jan-13 17:14pm
v2

1 solution

You cannot control the way Date is stored in database. Instead while retrieving you can format it the way you want and display in front end.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900