Click here to Skip to main content
15,890,512 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Data Services

public static void AddNewMaterial(int material_id, string material, string UTP, string Use_Type,string Salt, string Salt_Type)
  {
  OracleDatabase db =(OracleDatabase)DatabaseFactory.CreateDatabase("PHTS");
 using (System.Data.Common.DbCommand cmd = db.GetStoredProcCommand("AddNewMaterial"))  
           {
  db.AddInParameter(cmd, "I_Material_ID", DbType.Int32, material_id);
  db.AddInParameter(cmd, "I_Material", DbType.String, material);
  db.AddInParameter(cmd, "I_UTP", DbType.String, UTP);
  db.AddInParameter(cmd, "I_Use_Type", DbType.String, Use_Type);
  db.AddInParameter(cmd, "I_Salt", DbType.String, Salt);
  db.AddInParameter(cmd, "I_Salt_Type", DbType.String, Salt_Type);
  db.ExecuteNonQuery(cmd);
            }
  }


UserInterface

private void Savebutton_Click(object sender, EventArgs e)
        {
            int material_id = Convert.ToInt32(this.MIDtextBox.Text);
            string material = this.MaterialtextBox.Text;
            string UTP = this.UTPcheckBox.Text;
            string Use_Type = this.UseTypecomboBox.Text;
            string Salt = this.SaltCheckbox.Text;
            string Salt_Type = this.SaltComboBox.Text;
            
PHTS.DataServices.cslMaterial.AddNewMaterial(material_id, material, UTP, Use_Type,Salt, Salt_Type);
            MessageBox.Show("Record Saved");
            
        }


How can I save the Checkbox.checked Item to database as “Y” and if is not checked then I have to save as "N"

Thanks
Posted

1 solution

C#
string isChecked = checkbox1.Checked ? "Y" : "N";


Now you have the desired string that you can save in the database (however you're choosing to do that). It ain't rocket surgery.
 
Share this answer
 
Comments
rbjanaki 1-Aug-11 16:31pm    
Thanks for your solution now I am getting this error
"
ORA-06550: line 1, column 7:
PLS-00306: wrong number or types of arguments in call to 'ADDNEWMATERIAL'
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored"
rbjanaki 4-Aug-11 17:10pm    
now how can bind the checkbox.checked property,forexample in the database UTP is saved a Y or N. If it is Y the checkbox has to show checked.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900