c# - how to get radio button valuse and store in mysql database -
I want to store radio button values as men and women in the mysql database, so I have c # / P>
Here is my C # code
Private Zero addButton_Click (Object Sender, RoutedEventArgs E) {try {string query = @ "bcasdb`. 'Tbl_student` Reg_id`,` std_fname`, `Std_lname`,` tbl_batch_batch_id`, `gender`) value (@regId, @fName, @lName, @bid, @gender)"; // This is the command class which will handle the query and the connection object. MySqlConnection conn = New MySqlConnection (BCASApp.DataModel.DB_CON.connection); MySqlCommand CMD = New MySqlCommand (query, conn); Conn.Open (); Cmd.Parameters.AddWithValue ("@ regId", this.regIDInput.Text); Cmd.Parameters.AddWithValue ("@FName", this.fnameInput.Text); Cmd.Parameters.AddWithValue ("@ lName", this.lnameInput.Text); Cmd.Parameters.AddWithValue ("@ BID", this.batchIDInput.Text); //cmd.Parameters.AddWithValue(_@gender "); cmd.ExecuteNonQuery (); conn.Close (); successmsgBox ();} hold (exception) {errormsgBox ();}} Private zero gender Input_Checked (object sender , RoutedEventArgs E) {} Here's my xaml coding
string gender = maleInput.Ischecked? "M": "F"; Cmd.Parameters.AddWithValue ("gender", gender); Believe that selection is necessary if no selection is valid:
string gender = faucet; If (maleInput.Is checked) (female input .iis check) {gender = maleInput.Checked? "M": "F"; } Cmd.Parameters.AddWithValue ("gender", gender);
Comments
Post a Comment