0

Additional information:

An error occurred while attempting to initialize a System.Data.SqlClient.SqlConnection object. The value that was provided for the connection string may be wrong, or it may contain an invalid syntax.

I'm creation new role in my web application. When i add new role i got an error i don't have any idea about it kindly help me.

Connection string :

<connectionStrings>
    <add name="PayRollContext" connectionString="metadata=res://*/PayRollDataModel.csdl|res://*/PayRollDataModel.ssdl|res://*/PayRollDataModel.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=ATI_SHAH\SQLEXPRESS;initial catalog=PayRollManagmentSystem;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" />
  </connectionStrings>

Controller where i get an error here: {var chkRole = Roles.RoleExists(rolename);}

public ActionResult CreatRole(aspnet_Roles role)
{
    string rolename = role.RoleName;
    if (ModelState.IsValid)
    {
        var chkRole = Roles.RoleExists(rolename);
        if (chkRole == true)
        {
            ModelState.AddModelError("Name", "* Role Already Exist");
        }
        else
        {
            Roles.CreateRole(rolename);
            return RedirectToAction("ListRole", "Role");
        }
    }
    return View();
}
Ryan Vincent
  • 4,483
  • 7
  • 22
  • 31
shujaat ali
  • 29
  • 1
  • 9

1 Answers1

0

The rest of the data in there (the metadata, etc.) is just confusing SQL Server.

<add name="PayRollContext" connectionString="data source=ATI_SHAH\SQLEXPRESS;initial catalog=PayRollManagmentSystem;multipleactiveresultsets=True;integrated security=True;App=EntityFramework">
Kaushik Maheta
  • 1,741
  • 1
  • 18
  • 27
  • Thanks @kaushik it add role in database but after adding roll i want to redirect to list of roles, is it possible to do this ? i get an exception , "Additional information: Keyword not supported: 'data source'. " – shujaat ali Sep 12 '15 at 10:16