我正在尝试连接到数据库。我在页面顶部加载了以下内容:
using System.Data.SqlClient;
using System.Data;
这是我的数据集代码:
DataSet Data = new DataSet();
using (SqlDataAdapter DataAdapter = new SqlDataAdapter(Command))
{
DataAdapter.Fill(Data);
}
还有我的 project.json:
{
"webroot": "wwwroot",
"version": "1.0.0-*",
"compilationOptions": {
"emitEntryPoint": true
},
"dependencies": {
"Microsoft.AspNet.IISPlatformHandler": "1.0.0-rc1-final",
"Microsoft.AspNet.Server.Kestrel": "1.0.0-rc1-final",
"Microsoft.AspNet.Mvc": "6.0.0-rc1-final",
"Microsoft.AspNet.StaticFiles": "1.0.0-rc1-final",
"EntityFramework.MicrosoftSqlServer": "7.0.0-rc1-final",
"EntityFramework.Relational": "7.0.0-rc1-final"
},
"commands": {
"web": "Microsoft.AspNet.Server.Kestrel"
},
"frameworks": {
"dnx451": {
"frameworkAssemblies": {
}
},
"dnxcore50": { }
},
"exclude": [
"wwwroot",
"node_modules"
],
"publishExclude": [
"**.user",
"**.vspscc"
]
}
它没有在我的 DataSet 下划线,但是当我尝试构建它时返回错误:
The type or namespace name 'DataSet' could not be found (are you missing a using directive or an assembly reference?)
我假设程序集引用是在谈论我的依赖项。那么我需要什么依赖才能访问 DataSet?我在网上查了一下,只发现有人列出了没有版本号的 .dll 文件之类的东西。正如您从我的依赖项中看到的那样,我看不到可以列出文件和需要版本的地方。
最佳答案
数据集在命名空间 System.Data 下 System.Data
所以要使用它,您必须添加对 System.Data
程序集的引用。
通常它与安装的 .Net 框架一起打包。 因此,如果您使用的是 VS,请按照以下步骤添加:
- 在您的项目根目录中,右键单击
References
- 点击
添加引用
- 在弹出窗口的程序集部分下,选择框架
- 最后,找到并检查 System.Data 程序集
关于c# - DataSet 在什么依赖中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37670767/