TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Deepak Sharma
NA
143
11.1k
Gender Selection
Mar 27 2017 6:24 AM
Hi
i have created a regestration page in that there is name,username,password,date of birth,Gender.
when i'm clicking on save button data is saved successfully in the database but in the Gender field insted of Male or Female it is coming 1.
please help me with perfect code.
private void button1_Click(object sender, EventArgs e)
{
if (textBox1.Text != "" && textBox2.Text != "" && textBox3.Text != "" && comboBox2.Text != ""
&& textBox5.Text != "" && textBox6.Text != "" && textBox7.Text != "" && textBox8.Text != ""
&& textBox9.Text != "" && comboBox1.Text != "" && comboBox3.Text != ""
&& textBox13.Text != "" && textBox14.Text != "" && textBox15.Text != "" && textBox16.Text != ""
&& textBox17.Text != "" && comboBox4.Text != "" && dateTimePicker1.Text != ""
&& dateTimePicker2.Text != "")
{
cmd = new SqlCommand("insert into Empandadmin(Role,EmpId,Name,DOB,Gender,DOJ,Desgination,Username,Password,PanNo,BankName,AccountNo,City,State,Zip,Email,Mobile,Alternetno,Experiance,Createdby)Values(@Role,@EmpId,@Name,@DOB,@Gender,@DOJ,@Desgination,@Username,@Password,@PanNo,@BankName,@AccountNo,@City,@State,@Zip,@Email,@Mobile,@Alternetno,@Experiance,@Createdby)",con);
cmd.Parameters.AddWithValue("@Role" ,textBox1.Text);
cmd.Parameters.AddWithValue("@EmpId", textBox2.Text);
cmd.Parameters.AddWithValue("@Name", textBox3.Text);
cmd.Parameters.AddWithValue("@DOB", dateTimePicker1.Value);
cmd.Parameters.AddWithValue("@Gender", radioButton1.Checked);
//cmd.Parameters.AddWithValue("@Gender", checkBox2.Checked);
cmd.Parameters.AddWithValue("@DOJ", dateTimePicker2.Value);
cmd.Parameters.AddWithValue("@Desgination", comboBox1.Text);
cmd.Parameters.AddWithValue("@Username", textBox5.Text);
cmd.Parameters.AddWithValue("@Password", textBox6.Text);
cmd.Parameters.AddWithValue("@PanNo", textBox7.Text);
cmd.Parameters.AddWithValue("@BankName", textBox8.Text);
cmd.Parameters.AddWithValue("@AccountNo", textBox9.Text);
//cmd.Parameters.AddWithValue("@Address", textBox10.Text);
cmd.Parameters.AddWithValue("@City", comboBox3.Text);
cmd.Parameters.AddWithValue("@State", comboBox2.Text);
cmd.Parameters.AddWithValue("@Zip", textBox13.Text);
cmd.Parameters.AddWithValue("@Email", textBox14.Text);
cmd.Parameters.AddWithValue("@Mobile", textBox15.Text);
cmd.Parameters.AddWithValue("@Alternetno", textBox16.Text);
cmd.Parameters.AddWithValue("@Experiance", textBox17.Text);
cmd.Parameters.AddWithValue("@Createdby", comboBox4.Text);
con.Open();
cmd.ExecuteNonQuery();
con.Close();
MessageBox.Show("Employee added Successfully");
}
}
Database Output :
Reply
Answers (
8
)
Product sales form
Directory not created during Custom Action, VS2010 Installer