Guys, Need some expert advise and help. I am a NooB, trying to create a small Windows Form Application that would insert some data into MY SQL Database. On this form, I am using 3 Combo Box, 1 Text Box, 1 Datetime picker and one button for the save action. The Application works fine, the way it is intended to, but the only problem is time does not get updated after every record is inserted to the table. Time remains Constant. Below is the Code, kindly help.
Regards
Jagadish K
private void Save_Click(object sender, EventArgs e)
{
string sDispatcher = DispatcherName.Text;
string sDPSNum = DispatchNumber.Text;
string sDPSType = DPSType.Text;
DateTime dtDT = dateTimePickerDT.Value;
string sQueue = QG.Text;
string query = "INSERT INTO dps_data(DispatcherName, DispatchNumber, DPSType, DateTime, Queue)" +"VALUES( @Dispatcher, @DPSNum, @DPSType, @DT, @Queue)";
SqlConnection conn = new SqlConnection(connection);
SqlCommand cmd = new SqlCommand(query, conn);
conn.Open();
cmd.Parameters.Add(new SqlParameter("@Dispatcher", sDispatcher));
cmd.Parameters.Add(new SqlParameter("@DPSNum", sDPSNum));
cmd.Parameters.Add(new SqlParameter("@DPSType", sDPSType));
cmd.Parameters.Add(new SqlParameter("@DT", dtDT));
cmd.Parameters.Add(new SqlParameter("@Queue", sQueue));
int result = cmd.ExecuteNonQuery();
if (result > 0)
{
MessageBox.Show("Data Added Successfully");
}
else
{
MessageBox.Show("Error in Adding Data");
}
conn.Close();
DispatchNumber.Text = String.Empty;
DPSType.Text = String.Empty;
QG.Text = String.Empty;
}
}
[Edit - Marcus Kramer Added pre tags and removed irrelevant code]