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 MenothPosted Aug 5, 2015, 9:01 AM
Rajeesh MenothPosted Aug 6, 2015, 2:39 AM
IsraelPosted Aug 5, 2015, 10:48 AM
IsraelPosted Aug 5, 2015, 9:18 AM
Upendra Pratap ShahiPosted Aug 5, 2015, 8:57 AM
Upendra Pratap ShahiPosted Aug 5, 2015, 8:52 AM
IsraelPosted Aug 5, 2015, 8:49 AM
Upendra Pratap ShahiPosted Aug 5, 2015, 8:42 AM
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();
}