Hi!
I need to save in my database from my datetimepicker only the MONTH and YEAR. But its doesnt works.
Then see what I do and help me to resolv my problem please:
conn = new OleDbConnection(connstr);
comm = new OleDbCommand();
conn.Open();
OleDbParameter name = new OleDbParameter("@name", SqlDbType.VarChar);
OleDbParameter monthyear = new OleDbParameter("@monthyear", SqlDbType.VarChar);
comm.Parameters.Add(name);
comm.Parameters.Add(monthyear);
name.Value = txtName.Text;
monthyear .Value = txtMonthYear.Text;
comm.Connection = conn;
comm.CommandText = "insert into DBTest ([name],[monthyear]) values(@name,@monthyear)";
if(MessageBox.Show("Are you sure to save?","Windows for Save",MessageBoxButtons.YesNo) == DialogResult.Yes)
{
try
{
comm.ExecuteNonQuery();
MessageBox.Show("Saved...");
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
finally
{
conn.Close();
}

Rajeesh MenothRank #118 · 18.4K reputationPosted Aug 5, 2015, 5:01 AM EDT
Upendra Pratap ShahiRank #329 · 7.5K reputationPosted Aug 5, 2015, 4:42 AM EDT
public static void InsertFileLog(string fileName,DateTime crDate,DateTime modDate,DateTime uploadTime)
{
OleDbConnection conn = GetConnection();
string strQuery1 = @"insert into FileLog(FileName,CreateDate,ModifiedDate,UploadedOn) values('" + fileName + "','"+crDate+"','"+modDate+"','"+uploadTime+"')";
OleDbCommand olCommond1 = new OleDbCommand(strQuery1, conn);
olCommond1.ExecuteNonQuery();
conn.Close();
}
IsraelRank #1,223 · 1.5K reputationPosted Aug 5, 2015, 4:49 AM EDT
Upendra Pratap ShahiRank #329 · 7.5K reputationPosted Aug 5, 2015, 4:52 AM EDT
Upendra Pratap ShahiRank #329 · 7.5K reputationPosted Aug 5, 2015, 4:57 AM EDT
IsraelRank #1,223 · 1.5K reputationPosted Aug 5, 2015, 5:18 AM EDT
IsraelRank #1,223 · 1.5K reputationPosted Aug 5, 2015, 6:48 AM EDT
Rajeesh MenothRank #118 · 18.4K reputationPosted Aug 5, 2015, 10:39 PM EDT