i have a Winform App that stores about 19 textbox data in an Access Database..
as far as i can tell, i'm entering all possible data in them before executing nonquery command...
here is my command text
subcom.CommandText = @"Insert Into GOA_DB (Srno, Branch_Code, Branch_Name, Node,
Region, Date_Comm, Address, MPLS, Leased_Line, LL_IP, Router_WAN_IP, Router_LAN_IP,
Distance_from_RCC, OATM_Parent_details, Curcuit_ID, Circuit_Type, G703_used, G703_srno,
V35_used, V35_srno, Bandwidth, Router_Make_Model, Router_srno, Router_vendor,
Backup_link, BckUP_Vendor, BcKup_WAN_IP ) Values (@Srno, @Branch_Code, @Branch_Name,
@Node, @Region, @Date_Comm, @Address, @MPLS, @Leased_Line, @LL_IP, @Router_WAN_IP,
@Router_LAN_IP, @Distance_from_RCC, @OATM_Parent_details, @Curcuit_ID,
@Circuit_Type, @G703_used, @G703_srno, @V35_used, @V35_srno, @Bandwidth,
@Router_Make_Model, @Router_srno, @Router_vendor, @Backup_link, @BckUP_Vendor,
@BcKup_WAN_IP )";
here are my parameters.
subcom.Parameters.AddWithValue(@"Srno", label26.Text);
subcom.Parameters.AddWithValue(@"Branch_Code", textBox1.Text);
subcom.Parameters.AddWithValue(@"Branch_Name", textBox2.Text);
subcom.Parameters.AddWithValue(@"Node", textBox3.Text);
subcom.Parameters.AddWithValue(@"Region", textBox4.Text);
subcom.Parameters.AddWithValue(@"Date_Comm", dateTimePicker1.Text);
subcom.Parameters.AddWithValue(@"Address", textBox5.Text);
if (radioButton1.Checked)
{
string yes = "Yes";
subcom.Parameters.AddWithValue(@"MPLS", @yes);
subcom.Parameters.AddWithValue(@"Leased_Line", textBox15.Text);
subcom.Parameters.AddWithValue(@"LL_IP", textBox15.Text);
}
if (radioButton2.Checked)
{
string Y = "Yes";
string na1 = "Not Applicable";
subcom.Parameters.AddWithValue(@"Leased_Line", @Y);
subcom.Parameters.AddWithValue(@"MPLS", @na1);
subcom.Parameters.AddWithValue(@"LL_IP", textBox15.Text);
}
subcom.Parameters.AddWithValue(@"Router_WAN_IP", textBox8.Text);
subcom.Parameters.AddWithValue(@"Router_LAN_IP", textBox9.Text);
subcom.Parameters.AddWithValue(@"Distance_from_RCC", textBox6.Text);
subcom.Parameters.AddWithValue(@"OATM_Parent_details", textBox7.Text);
subcom.Parameters.AddWithValue(@"Curcuit_ID", textBox10.Text);
if (radioButton3.Checked)
{
string ml = "MLLN";
string No = "No";
subcom.Parameters.AddWithValue(@"Circuit_Type", radioButton3.Text);
subcom.Parameters.AddWithValue(@"G703_used", No);
subcom.Parameters.AddWithValue(@"V35_used", No);
subcom.Parameters.AddWithValue(@"V35_used", @No);
subcom.Parameters.AddWithValue(@"V35_srno", textBox17.Text);
}
//to enter non-mlln details
if (radioButton4.Checked)
{
string yes3 = "Yes";
//string non = "Non-MLLN";
subcom.Parameters.AddWithValue(@"Circuit_Type", radioButton4.Text);
subcom.Parameters.AddWithValue(@"G703_used", yes3);
subcom.Parameters.AddWithValue(@"G703_srno", textBox16.Text);
subcom.Parameters.AddWithValue(@"V35_used", yes3);
subcom.Parameters.AddWithValue(@"V35_srno", textBox17.Text);
}
subcom.Parameters.AddWithValue(@"Bandwidth", comboBox1.Text);
subcom.Parameters.AddWithValue(@"Router_Make_Model", textBox13.Text);
subcom.Parameters.AddWithValue(@"Router_srno", textBox14.Text);
subcom.Parameters.AddWithValue(@"Router_vendor", textBox12.Text);
if (radioButton5.Checked)
{
subcom.Parameters.AddWithValue(@"Backup_link", radioButton5.Text);
subcom.Parameters.AddWithValue(@"BckUp_vendor", textBox18.Text);
subcom.Parameters.AddWithValue(@"Bck_WAN_IP", textBox19.Text);
}
if (radioButton6.Checked)
{
subcom.Parameters.AddWithValue(@"Backup_link", radioButton6.Text);
subcom.Parameters.AddWithValue(@"BckUp_vendor", textBox18.Text);
subcom.Parameters.AddWithValue(@"Bck_WAN_IP", textBox19.Text);
}
if (null2(this))
{
// MessageBox.Show("Some empty values are present");
try
{
int resul = subcom.ExecuteNonQuery();
if (resul > 0)
{
MessageBox.Show("Entered Successfully");
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
Here the exception thrown is No value given for one or more required parameters... execution stops...
any clue?
See Question&Answers more detail:
os