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
Ali Ashiq
NA
61
32.4k
how could i store information in database and redirect page
Feb 12 2014 6:46 AM
Here is my code and when i fill all required fields it will not navigate to another page! what is the error and i want to check if email is already exist it will show error message Email already exists
protected void btnRegister_Click(object sender, EventArgs e)
{
SqlConnection myConnection = new SqlConnection(@"Data Source=ALIASHIQ\SQL2013;Initial Catalog=Person;Integrated Security=True");
SqlCommand cmd = new SqlCommand("INSERT INTO UserData(FirstName,LastName,Email,Mobile,Address,Password) VALUES (@Name,@LastName,@Email,@Mobile,@Address,@Password)", myConnection);
cmd.CommandType = CommandType.Text;
//if (txtEmail.Text == txtEmail.Text)
// {
cmd.Parameters.AddWithValue("@Name", txtName.Text);
cmd.Parameters.AddWithValue("@LastName", txtLastName.Text);
cmd.Parameters.AddWithValue("@Email", txtEmail.Text);
cmd.Parameters.AddWithValue("@Mobile", txtMobile.Text);
cmd.Parameters.AddWithValue("@Address", txtAddress.Text);
cmd.Parameters.AddWithValue("@Password", txtPassword.Text);
// cmd.Parameters.AddWithValue("@Password", txtPassword.Text);
myConnection.Open();
cmd.ExecuteNonQuery();
myConnection.Close();
Response.Redirect("contenctwelcome.aspx");
//}
//else
//{
// ErrorMessage.Text = "Please enter all fields";
//}
Reply
Answers (
0
)
C# code to allow only a checkbox selected in listview
Search Content of eBooks.