DataSet myDataSet = new DataSet();
string sConnect;
sConnect = "initial catalog=Student Information; Server = CUTEMITE";
SqlConnection dbConn = new SqlConnection(sConnect);
try
{
SQL.SqlCommand dbCmd;
dbCmd = new SQL.SqlCommand(qurey,dbConn); SQL.SqlDataAdapter dbAdapter;
dbAdapter = new SQL.SqlDataAdapter(dbCmd);
dbConn.Open();
dbAdapter.Fill(myDataSet);
dbConn.Close();
}
catch (Exception ex)
{
throw ex;
}
finally
{
dbConn.Close();
} return myDataSet;
为什么一直有错啊?Error 2 The type or namespace name 'SqlConnection' could not be found (are you missing a using directive or an assembly reference?) E:\520\c\SIS\SIS\DB.cs 91 13 SISError 4 The best overloaded method match
for 'System.Data.SqlClient.SqlCommand.SqlCommand(string, System.Data.SqlClient.SqlConnection)' has some invalid arguments E:\520\c\SIS\SIS\DB.cs 97 25 SIS请教高手~~
string sConnect;
sConnect = "initial catalog=Student Information; Server = CUTEMITE";
SqlConnection dbConn = new SqlConnection(sConnect);
try
{
SQL.SqlCommand dbCmd;
dbCmd = new SQL.SqlCommand(qurey,dbConn); SQL.SqlDataAdapter dbAdapter;
dbAdapter = new SQL.SqlDataAdapter(dbCmd);
dbConn.Open();
dbAdapter.Fill(myDataSet);
dbConn.Close();
}
catch (Exception ex)
{
throw ex;
}
finally
{
dbConn.Close();
} return myDataSet;
为什么一直有错啊?Error 2 The type or namespace name 'SqlConnection' could not be found (are you missing a using directive or an assembly reference?) E:\520\c\SIS\SIS\DB.cs 91 13 SISError 4 The best overloaded method match
for 'System.Data.SqlClient.SqlCommand.SqlCommand(string, System.Data.SqlClient.SqlConnection)' has some invalid arguments E:\520\c\SIS\SIS\DB.cs 97 25 SIS请教高手~~
解决方案 »
- C# SetWindowLong 中的WM_Paste事件怎么获取不了
- 我是新手,麻烦各位前辈帮个小忙...我JS调用后天方法,在页面加载的时候为什么会自动调用后台方法了?
- 如何用C#操作WORD中文本框
- 网站会员中心的框架设计和布局(4个模块)
- 求故障树绘图布局算法...
- 读一文本文件到一DataSet?
- 求助!【请教问题】C# 实现自动登陆支付宝
- 如何访问
- 用DataGrid显示数据时,DataSource中的一列怎样不让其显示在DataGrid?但其值必须还存在在DataSet中
- 各位大哥,关于VC前途走向的请教。
- asp.net里cache怎么用?能大幅度提高系统效率吗?cache刷新好象不及时。
- 水晶报表问题请高手指教
using System.Data.SqlClient;
using System.Data.SqlClient;
写了的
using System.Data;
using System.Data.SqlClient;
SQLDataAdapter MyCommand; void Page_Load(object sender, EventArgs e)
{
MyConnection = new SqlConnection("server=localhost;Initial Catalog=pubs;uid=sa;pwd=");
if (!(IsPostBack)) {
BindGrid();
}
} void BindGrid()
{
SQLDataAdapter MyCommand = new SQLDataAdapter("SELECT * FROM authors", MyConnection);
DataSet DS = new DataSet();
MyCommand.Fill(DS, "min");
MyDataGrid.DataSource = DS.Tables("min").DefaultView;
MyDataGrid.DataBind();
}
2.连接字符串没有写正确
1.WINDOWS 不用写用户名与密码,但要加一句 integrated security=SSPI
2.SQL 要求输入用户名与密码
2.加入
using system.data;
using system.data.sqlclient;
3.连接字串写得有问题,未指明连接方式。