初始化字符串的格式不符合从索引 165 开始的规范
Format of the initialization string does not conform to specification starting at index 165
我不断收到此错误:
Format of the initialization string does not conform to specification starting at index 165.
我似乎找不到问题所在。
连接代码:
<connectionStrings>
<add name="DefaultConnection" connectionString="Data Source=(LocalDb)\v11.0;AttachDbFilename=|DataDirectory|\LarandeModulDB.mdf;Integrated Security=True" providerName="System.Data.SqlClient" />
<add name="LarandeModulDBEntities" connectionString="metadata=res://*/Models.EntityModel.LMDBModel.csdl|res://*/Models.EntityModel.LMDBModel.ssdl|res://*/Models.EntityModel.LMDBModel.msl;provider=System.Data.SqlClient;provider connection string="data source=(LocalDB)\v11.0;attachdbfilename="|DataDirectory|\LarandeModulDB.mdf"integrated security=True;MultipleActiveResultSets=True;App=EntityFramework"" providerName="System.Data.EntityClient" />
</connectionStrings>
我用来检索具有相同 ID 的 employee
的代码与登录人员的 ID 相同:
var employeeId = context.SchoolEmployee.FirstOrDefault(r => r.UserId.Equals(userId));
那个代码returns:
An exception of type 'System.ArgumentException' occurred in EntityFramework.dll but was not handled in user code
Additional information: Format of the initialization string does not conform to specification starting at index 165.
public List<Employee> GetClassInfo1( string userId)
{
using (var context = new LarandeModulDBEntities())
{
var list = new List<Employee>();
var employeeId = context.SchoolEmployee.FirstOrDefault(r => r.UserId.Equals(userId));
var c = context.Class.Where(r => r.TeacherId.Equals(employeeId.Id)).ToList();
foreach (var i in c)
{
var e = new Employee();
e.Grade = i.Grade;
e.Id = i.Id;
e.Name = i.Name;
e.TeacherId = i.TeacherId;
list.Add(e);
}
return list;
}
}
你可能copied/pasted把连接串连在一起了。 "
个符号太多:
connection string="
;data source=(LocalDB)\v11.0;attachdbfilename="
|DataDirectory|\LarandeModulDB.mdf"
integrated security=True;MultipleActiveResultSets=True;App=EntityFramework"
应该是
connection string="
data source=(LocalDB)\v11.0;attachdbfilename=|DataDirectory|\LarandeModulDB.mdf;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework"
我不断收到此错误:
Format of the initialization string does not conform to specification starting at index 165.
我似乎找不到问题所在。
连接代码:
<connectionStrings>
<add name="DefaultConnection" connectionString="Data Source=(LocalDb)\v11.0;AttachDbFilename=|DataDirectory|\LarandeModulDB.mdf;Integrated Security=True" providerName="System.Data.SqlClient" />
<add name="LarandeModulDBEntities" connectionString="metadata=res://*/Models.EntityModel.LMDBModel.csdl|res://*/Models.EntityModel.LMDBModel.ssdl|res://*/Models.EntityModel.LMDBModel.msl;provider=System.Data.SqlClient;provider connection string="data source=(LocalDB)\v11.0;attachdbfilename="|DataDirectory|\LarandeModulDB.mdf"integrated security=True;MultipleActiveResultSets=True;App=EntityFramework"" providerName="System.Data.EntityClient" />
</connectionStrings>
我用来检索具有相同 ID 的 employee
的代码与登录人员的 ID 相同:
var employeeId = context.SchoolEmployee.FirstOrDefault(r => r.UserId.Equals(userId));
那个代码returns:
An exception of type 'System.ArgumentException' occurred in EntityFramework.dll but was not handled in user code
Additional information: Format of the initialization string does not conform to specification starting at index 165.
public List<Employee> GetClassInfo1( string userId)
{
using (var context = new LarandeModulDBEntities())
{
var list = new List<Employee>();
var employeeId = context.SchoolEmployee.FirstOrDefault(r => r.UserId.Equals(userId));
var c = context.Class.Where(r => r.TeacherId.Equals(employeeId.Id)).ToList();
foreach (var i in c)
{
var e = new Employee();
e.Grade = i.Grade;
e.Id = i.Id;
e.Name = i.Name;
e.TeacherId = i.TeacherId;
list.Add(e);
}
return list;
}
}
你可能copied/pasted把连接串连在一起了。 "
个符号太多:
connection string=
"
;data source=(LocalDB)\v11.0;attachdbfilename="
|DataDirectory|\LarandeModulDB.mdf"
integrated security=True;MultipleActiveResultSets=True;App=EntityFramework"
应该是
connection string=
"
data source=(LocalDB)\v11.0;attachdbfilename=|DataDirectory|\LarandeModulDB.mdf;integrated security=True;MultipleActiveResultSets=True;App=EntityFramework"