I have an application with general customer detail.
It has TextBox and radio button.
First I have used if statement then code but on first step is working fine then error is showing. I'm not getting what I'm missing can any body guide me ....... - try
-
{
-
if (textBox1.Text == "")
-
{
-
MessageBox.Show("Please Enter The First Name");
-
//textBox1.Focus();
-
}
-
else if (radioButton1.Checked == false && radioButton2.Checked == false)
-
{
-
MessageBox.Show("Please Select The Gender ");
-
//radioButton1.Focus();
-
}
-
else if (checkBox1.Checked == false && checkBox2.Checked == false)
-
{
-
MessageBox.Show("Please Enter Your Phone Or Mobile Number");
-
//checkBox1.Focus();
-
}
-
else if (textBox6.Text == "")
-
{
-
MessageBox.Show("Please Enter Your Email Id");
-
//textBox6.Focus();
-
}
-
else if (radioButton3.Checked == false && radioButton4.Checked == false && radioButton5.Checked == false && radioButton6.Checked == false)
-
{
-
MessageBox.Show("Please Grade Us According To Our Service");
-
//radioButton3.Focus();
-
}
-
-
}
-
catch (Exception ex)
-
{
-
//MessageBox.Show("Please Fill The Required Blanks");
-
-
}
-
-
con.Open();
-
SqlCommand cmd = new SqlCommand();
-
cmd.Connection = con;
-
cmd.CommandType = CommandType.StoredProcedure;
-
cmd.CommandText = "insertpro";
-
cmd.Parameters.AddWithValue("@firstname", textBox1.Text);
-
cmd.Parameters.AddWithValue("@lastname", textBox2.Text);
-
if (radioButton1.Checked == true)
-
{
-
cmd.Parameters.AddWithValue("@gender", radioButton1.Text);
-
}
-
else if (radioButton2.Checked == true)
-
{
-
cmd.Parameters.AddWithValue("@gender", radioButton2.Text);
-
}
-
//else if (radioButton1.Checked == false && radioButton2.Checked ==false )
-
//{
-
// cmd.Parameters.AddWithValue("@gender","");
-
//}
-
cmd.Parameters.AddWithValue("@age", comboBox1.Text);
-
cmd.Parameters.AddWithValue("@company", textBox3.Text);
-
cmd.Parameters.AddWithValue("@profession", textBox10.Text);
-
cmd.Parameters.AddWithValue("@adress", textBox7.Text);
-
cmd.Parameters.AddWithValue("@city", textBox8.Text);
-
cmd.Parameters.AddWithValue("@date", DateTime.Today.TimeOfDay);
-
-
-
SqlCommand cmd1 = new SqlCommand();
-
cmd1.Connection = con;
-
cmd1.CommandType = CommandType.StoredProcedure;
-
cmd1.CommandText = "insertfeed";
-
cmd1.Parameters.AddWithValue("@contactnoph", textBox4.Text);
-
cmd1.Parameters.AddWithValue("@emailadress", textBox6.Text);
-
if (radioButton3.Checked == true)
-
{
-
cmd1.Parameters.AddWithValue("@remark", radioButton3.Text);
-
cmd1.Parameters.AddWithValue("@remarkid", 0);
-
}
-
else if (radioButton4.Checked == true)
-
{
-
cmd1.Parameters.AddWithValue("@remark", radioButton4.Text);
-
cmd1.Parameters.AddWithValue("@remarkid", 1);
-
}
-
else if (radioButton5.Checked == true)
-
{
-
cmd1.Parameters.AddWithValue("@remark", radioButton5.Text);
-
cmd1.Parameters.AddWithValue("@remarkid", 2);
-
}
-
else if (radioButton6.Checked == true)
-
{
-
cmd1.Parameters.AddWithValue("@remark", radioButton6.Text);
-
cmd1.Parameters.AddWithValue("@remarkid", 3);
-
}
-
else if (radioButton3.Checked == false && radioButton4.Checked == false && radioButton5.Checked == false && radioButton6.Checked == false)
-
{
-
cmd1.Parameters.AddWithValue("@remark", "");
-
cmd1.Parameters.AddWithValue("@remarkid", "");
-
}
-
if (comboBox2.SelectedIndex == 1)
-
{
-
cmd1.Parameters.AddWithValue("@sugession", textBox9.Text);
-
cmd1.Parameters.AddWithValue("@sugid", 1);
-
}
-
else if (comboBox2.SelectedIndex == 2)
-
{
-
cmd1.Parameters.AddWithValue("@sugession", textBox9.Text);
-
cmd1.Parameters.AddWithValue("@sugid", 2);
-
}
-
else if (comboBox2.SelectedIndex == 0)
-
{
-
cmd1.Parameters.AddWithValue("@sugession", textBox9.Text);
-
cmd1.Parameters.AddWithValue("@sugid", 0);
-
}
-
cmd1.Parameters.AddWithValue("@firstname", textBox1.Text);
-
cmd1.Parameters.AddWithValue("@contactnomob", textBox5.Text);
-
cmd.ExecuteNonQuery();
-
cmd1.ExecuteNonQuery();
-
con.Close();
-
MessageBox.Show("Thanks For Your Feed Back.");
-
textBox1.Text = "";
-
textBox2.Text = "";
-
textBox3.Text = "";
-
textBox4.Text = "";
-
textBox5.Text = "";
-
textBox6.Text = "";
-
textBox7.Text = "";
-
textBox8.Text = "";
-
textBox9.Text = "";
-
textBox10.Text = "";
-
comboBox1.SelectedIndex = 0;
-
comboBox2.SelectedIndex = 0;
-
radioButton1.Checked = false;
-
radioButton2.Checked = false;
-
radioButton3.Checked = false;
-
radioButton4.Checked = false;
-
radioButton5.Checked = false;
-
radioButton6.Checked = false;
-
checkBox1.Checked = false;
-
checkBox2.Checked = false;
-
-
}
-
5 1556
I can not understand what you are asking at all.
Hey Syed Hadi, where is the insert query in your code? (The insert query you wrote was wrong.)
You've to use like this... - SqlCommand myCommand = new SqlCommand("INSERT INTO TableName (Column1, Column2, ..., ColumnN) VALUES (@Param1, @Param2, ..., @ParamN)", myConnection);
-
myCommand.Parameters.AddWithValue("@Param1", variable1);
-
myCommand.Parameters.AddWithValue("@Param2", variable2);
-
...
-
myCommand.Parameters.AddWithValue("@ParamN", variableN);
-
myCommand.Open();
-
myCommand.ExecuteNonQuery();
-
myCommand.Close();
@vijay6 i m using procedure for inserting the values
@vijay6 i m using procedure for inserting the values
Okay.
Hey Syed Hadi, the mistake i noticed from your code is, codes from line number 36 to line number 134 should be placed inside the else statement after line number 27 in your code.
Yeah I did that.
Its right.
Thanks.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Laurel |
last post by:
this is driving me crazy. i need to use a form control as a criteria
in a select query, and the control's value is set depending upon what
a user selects in an option group on the form. the query...
|
by: Martin Lacoste |
last post by:
Is there some issue with using too many left/right/mid/len functions
in queries? Depending on the usage, they work fine, but... then
there's here:
SELECT Master_CAO.Incipit,...
|
by: news.paradise.net.nz |
last post by:
I have been developing access databases for over 5 years.
I have a large database and I have struck this problem with it before
but can find nothing in help or online. Access 2000
I have a query...
|
by: Manuel Arroba |
last post by:
asp.net oledb command parameter error calling an as400 program
Hi...
I have an as400 program that I can call it directly and it works:
variable= "xxxx"
sql = "CALL METSIGOP.SIGOPRC ('" +...
|
by: pmclinn |
last post by:
I have a formated a structure as follows:
<Serializable()>public structure stcOutPut
private data as string
private visi as string
end structure
Instances of this strucuture are stored in an...
|
by: Captain Gadget |
last post by:
I cannot update a child table to the main using the wizard criteria column
with out errors occuring.
I'm using ACCESS database 1 main table, 1 child.
The 2 tables are related, no problem.
I...
|
by: IMRAN |
last post by:
I have created a component which parses some flat
files and stores in Sql database. Now I want to move
that COM object to database server.
Now the scenario will be like this :
1) ASP page...
|
by: Damon |
last post by:
I've distilled this down into the simplest possible code fragment and
this still doesn't make any sense. I'm trying to run a select query on
an access database, and the query has NO parameters. ...
|
by: Magnus |
last post by:
I'm testing walkthrough saving data to a Database (Multiple Tables).
http://msdn2.microsoft.com/en-us/library/4esb49b4(VS.80).aspx
In the famous Customer/Order example, I'm getting referential...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
| |