kianoush dortaj
kianoush dortaj

Reputation: 1

connection to SQL SERVER in ASP.Net

I'm creating a register page . When I write connection string to connect to SQL Server 2014 , this error is shown: Error Pic

protected void btnsignup_Click(object sender, EventArgs e)
{
    SqlConnection con = new SqlConnection("server=(local);DataBase=MyDataBase;integrated security=True");
    SqlCommand cmd = new SqlCommand("insert into Users (Username,UPassword,Uname,UEmail) values ('"+ tbUname.Text + ","+ tbPass.Text + ","+tbname.Text +","+ tbemail.Text +"')");
    con.Open();
    cmd.ExecuteNonQuery();
    con.Close();
} 

Upvotes: 0

Views: 67

Answers (1)

counterflux
counterflux

Reputation: 383

Like the error message shows you cannot login as that user (IIS/defaultapppool) on SQL server. Ususally this happens if:

  1. User does not exist
  2. User does not have the permissions to access the database

Go to your SQL server management studio and make or edit your user. right click the security folder to make a new user, and make sure he is databaseReader, -Editor and/or databaseAdmin

You can also specify another user in your connectionstring by adding: User ID=name;Password=password

Upvotes: 3

Related Questions