I am beginner in asp.net and sql server. I have created a database in sql server 2014 with sql authentication.
Here is my code :
Registration.aspx.cs
public partial class Registration : System.Web.UI.Page
{
SqlConnection con = new SqlConnection(@"Data Source=DESKTOP-U9DUN78\SQLEXPRESS;Initial Catalog=LoginRegisterData;Persist Security Info=True;User ID=sa;Password=***********;Pooling=False");
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
try
{
con.Open();
SqlCommand cmd = con.CreateCommand();
cmd.CommandType = CommandType.Text;
cmd.CommandText = "insert into UserDetails values('" + TextBoxUsername.Text + "','" + TextBoxEmailid.Text+ "','" + TextBoxPassword.Text + "','" + TextBoxDate.Text + "','" + DropDownListCountry.SelectedItem + "')";
cmd.ExecuteNonQuery();
con.Close();
}
catch(Exception ee)
{
Response.Write(ee);
}
}
I want to store data into sql server database. The following snap is the error that I am getting :