public void Set_Query() { //--------- string command = "insert into Employee (Emp_ID,Emp_code,Date,time,Power,Phone,Salary) values ( @name, @code , @date , @time , @power , @phone , @salary ) "; try { DBAdapter.OPen(); SqlParameter[] param = new SqlParameter[7]; param[0] = new SqlParameter("@name", SqlDbType.NVarChar, 50); param[0].Value = this.Name; param[1] = new SqlParameter("@code", SqlDbType.NVarChar, 50); param[1].Value = this.Code; param[2] = new SqlParameter("@date", SqlDbType.NVarChar, 50); param[2].Value = DateTime.Now.ToShortDateString(); param[3] = new SqlParameter("@time", SqlDbType.NVarChar, 50); param[3].Value = DateTime.Now.ToLongTimeString(); param[4] = new SqlParameter("@power", SqlDbType.NVarChar, 50); param[4].Value = this.power; param[5] = new SqlParameter("@phone", SqlDbType.NVarChar, 50); param[5].Value = this.Phone; param[6] = new SqlParameter("@salary", SqlDbType.NVarChar, 50); param[6].Value = this.Salary; _do.Execute_Query(command, param); } catch (SqlException ex) { Alert.Show(ex.Message); } finally { DBAdapter.Close(); Alert.Show("Employee Added Successfuly"); } //------- }
public void Set_Query() { string command = "insert into Car (ID,char,date,time) values (@id,@char,@date,@time) "; try { DBAdapter.OPen(); SqlParameter[] param = new SqlParameter[4]; param[0] = new SqlParameter("@id", SqlDbType.NVarChar, 50); param[0].Value = this.Car_ID; param[1] = new SqlParameter("@char", SqlDbType.NVarChar, 50); param[1].Value = this.Car_Char; param[2] = new SqlParameter("@date", SqlDbType.NVarChar, 50); param[2].Value = DateTime.Now.ToShortDateString(); param[3] = new SqlParameter("@time", SqlDbType.NVarChar, 50); param[3].Value = DateTime.Now.ToLongTimeString(); _do.Execute_Query(command, param); } catch (SqlException ex) { MessageBox.Show(ex.Message); } finally { DBAdapter.Close(); } //------- }