1
IDbConnection donn;
string dstr = "Server=.;Initial Catalog=master;Integrated Security=sspi";
donn.ConnectionString = dstr.ToString();
DataContext context = new DataContext(donn);
找到上面的代码片段donn变量是为IDbConnection,我不能设置它的属性ConnectionString
。在该行(3号线),它显示了一个错误 -对DataContext的IDbconnection使用未分配的局部变量错误。
'Use of unassigned local variable 'donn''
请帮助..
好 - 错误消息说,到底是什么问题:你没有分配一个值DONN。你刚刚宣布它。你错过了带'new'的部分。 –
接口和抽象类永远不会初始化使用新的 – pvaju896
这就是为什么我没有提供示例代码 - 我不知道你正在使用哪个具体的'IDbConnection'实现。 –