i am using below code but i am using windows authentication. visual studio is showing below error.
"A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)"
Please let me know how to use windows authentication for database connection.
What I have tried:
protected void Button1_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection("server=hp-pc;database=admin.mdf");
con.Open();
string q = "insert into (user_id,name,password,email_id,contact,user_type) values('" + TextBox1.Text + "','" + TextBox2.Text + "','" + TextBox3.Text + "','" + TextBox4.Text + "','" + TextBox5.Text + "')";
SqlCommand com = new SqlCommand(q, con);
com.ExecuteNonQuery();
Response.Write("alert('saved')");
Response.Redirect("index.aspx");