c# 如何读取数据库中table里面的数据
3个回答
展开全部
private DataSet dbConnection(string DatabaseConnectionString, string command)
{
using (SqlConnection myConnection = new SqlConnection(DatabaseConnectionString))
{
myConnection.Open();
using (SqlDataAdapter Adapter = new SqlDataAdapter(command, myConnection))
{
ds = new DataSet("new");
Adapter.Fill(ds, "new");
Adapter.Dispose();
myConnection.Close();
}
}
return ds;
}
return的dataset就是你要的table
{
using (SqlConnection myConnection = new SqlConnection(DatabaseConnectionString))
{
myConnection.Open();
using (SqlDataAdapter Adapter = new SqlDataAdapter(command, myConnection))
{
ds = new DataSet("new");
Adapter.Fill(ds, "new");
Adapter.Dispose();
myConnection.Close();
}
}
return ds;
}
return的dataset就是你要的table
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
SqlConnection conn = new SqlConnection("server=.;database=数据库;uid=sa;pwd=");
string sql = "select * from table";
SqlDataAdapter da = new SqlDataAdapter(sql,conn);
DataSet ds = new DataSet();
da.Fill(ds);
DataList.DataSource = ds.Tables[0].DefaultView;
DataList.databand();
string sql = "select * from table";
SqlDataAdapter da = new SqlDataAdapter(sql,conn);
DataSet ds = new DataSet();
da.Fill(ds);
DataList.DataSource = ds.Tables[0].DefaultView;
DataList.databand();
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询