hi all,
i am having some issues in saving the date in sql server 2000.
from my application i have save the data with date format "mm/dd/yyyy"-"07-11-2011". I have checked it's sending the data with this format to the sql server.
but when i check in the sql server it save as "2011-11-07 00:00:00.000" this format.
when i'm retrieving from the report it comes as "2011-yyyy",11-mm"","07-dd" for this issue what can i do?
please any one help me in this case...
below are the codes....
<b>add to the sql server</b>
<pre>public void AddTimesheet(DateTime Dtpicker, int cmbEmpno, string txtEmpname, string txtLocation, string cmbMode, string cmbOtmode, int txtNormalOT, int txtDayofOT)
{
string sqlstr;
sqlstr = "INSERT INTO Master (cDate,Emp_Number,Emp_Name,Work_Location,Mode,OTMode,Normal_OT,DayOff_OT)" +
" VALUES ( '" + Dtpicker + "'," + cmbEmpno + ", '" + txtEmpname + "','" + txtLocation + "','" + cmbMode + "', '" + cmbOtmode + "'," + txtNormalOT + "," + txtDayofOT + ")";
con = new SqlConnection(clsConnection.strconnection);
con.Open();
da = new SqlDataAdapter();
da.InsertCommand = new SqlCommand();
da.InsertCommand.Connection = con;
da.InsertCommand.CommandText = sqlstr;
da.InsertCommand.CommandType = CommandType.Text;
da.InsertCommand.ExecuteNonQuery();
DateTime datetimepic = Convert.ToDateTime(Dtpicker.Value.Date);
int empno = Convert.ToInt32(cmbEmpno.Text);
string empname = txtEmpname.Text;
string emplocation = txtLocation.Text;
string mode = cmbMode.Text;
string otmode = cmbOtmode.Text;
int normalot = Convert.ToInt32(txtNormalOT.Text);
int dayoffot = Convert.ToInt32(txtDayofOT.Text);
Classes.clsAttendance att = new testing.Classes.clsAttendance();
att.AddTimesheet(datetimepic, empno, empname, emplocation, mode, otmode, normalot, dayoffot);</pre>
<b>report code</b>
<pre>DateTime Datefrom = Convert.ToDateTime(dateFrom.Value.Date);
DateTime Dateto =Convert.ToDateTime( dateTo.Text);
string Location1 = Location.Text;
string Mode1 = Mode.Text;
string Otmode = otmode.Text;
string sqlstr = "SELECT * FROM Master ORDER BY Emp_Number";
con = new SqlConnection(clsConnection.strconnection);
con.Open();
DataSet ds = new DtReport();
DataTable dt = new DataTable();
SqlDataAdapter da = default(SqlDataAdapter);
da = new SqlDataAdapter(sqlstr, con);
da.Fill(dt);
foreach (DataRow row in dt.Rows)
{
ds.Tables["Master"].ImportRow(row);
}
rptreport objreport = new rptreport();
objreport.SetDataSource(ds);
objreport.SetParameterValue("Datefrom", dateFrom.Value.Date);
objreport.SetParameterValue("Dateto", dateTo.Text);
objreport.SetParameterValue("Location", Location1);
objreport.SetParameterValue("Mode", Mode1);
objreport.SetParameterValue("Otmode", Otmode);
crystalReportViewer1.ReportSource = objreport;
crystalReportViewer1.Show();</pre>