0

附加信息:

尝试初始化 System.Data.SqlClient.SqlConnection 对象时出错。为连接字符串提供的值可能是错误的,或者它可能包含无效的语法。

我正在role我的网络应用程序中创建新的。当我添加新角色时,我error对它一无所知,请帮助我。

连接字符串:

<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我在这里得到一个错误:{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();
}
4

1 回答 1

0

那里的其余数据(元数据等)只是让 SQL Server 感到困惑。

<add name="PayRollContext" connectionString="data source=ATI_SHAH\SQLEXPRESS;initial catalog=PayRollManagmentSystem;multipleactiveresultsets=True;integrated security=True;App=EntityFramework">
于 2015-09-12T09:48:35.377 回答