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
Abdulrhman Mohamed
NA
3
597
I am try to insert new user in database but exception throw
May 18 2016 5:55 AM
SqlConnection sqlconnection = new SqlConnection("Data Source=(local);Initial Catalog=supermarket;Integrated Security=True");
SqlCommand sqlcom = new SqlCommand();
sqlcom.Connection = sqlconnection;
try
{
sqlconnection.Open();
if (radioButton1.Checked)
{
sqlcom.CommandText = "insert into CUSTOMERS values('" + textBox2.Text + "','" + textBox3.Text + "','" + textBox1.Text+ "','" + radioButton1.Text + "')";
sqlcom.ExecuteNonQuery();
sqlconnection.Close();
MessageBox.Show("Inserted successfully! ");
}
if(radioButton2.Checked)
{
sqlcom.CommandText = "INSERT INTO CUSTOMERS VALUES('" + textBox2.Text + "','" +textBox3.Text + "','" + textBox1.Text + "','" + radioButton2.Text + "')";
sqlcom.ExecuteNonQuery();
sqlconnection.Close();
MessageBox.Show("Inserted successfully! ");
}
}
catch (Exception)
{
MessageBox.Show("Error inserting Customer or Customer already exists!");
}
}
Reply
Answers (
3
)
datepicker query
Packing nuget package in my dll