首先,我对 LINQ to SQL 很陌生,所以这可能是一个愚蠢的问题,但我正在尝试向数据库中插入一条新记录,但我不断收到以下错误:
The client was unable to establish a connection because of an error during connection initialization process before login. Possible causes include the following: the client tried to connect to an unsupported version of SQL Server; the server was too busy to accept new connections; or there was a resource limitation (insufficient memory or maximum allowed connections) on the server. (provider: Shared Memory Provider, error: 0 - The handle is invalid.)
我可以单步执行我的代码并看到所有数据都按我的预期出现,但是当它到达
db.SubmitChanges()
在下面的方法中,我得到了错误。我究竟做错了什么?这太令人沮丧了,我花了一天时间试图弄清楚 LINQ to SQL...
public static void Save(Customer customerToSave)
{
IpmDatabaseDataContext db = new IpmDatabaseDataContext();
db.Customers.InsertOnSubmit(customerToSave);
// commit the changes to the db
db.SubmitChanges();
}
在我的 app.config 它有这个连接字符串:
<connectionStrings>
<add name="IPM.Business.Properties.Settings.IPMConnectionString"
connectionString="Data Source=socrates\sqlexpress;Initial Catalog=IPM;Integrated Security=True"
providerName="System.Data.SqlClient" />
</connectionStrings>
我仍在我的开发机器上,所以这是正确的连接字符串。