c# 怎么创建dao
展开全部
你的意思是创建ado数据库连接么?
//获得DataSet
string connectionString = "Data Source=192.168.0.x;Initial Catalog=xxxx;User ID=xxxx;Password=xxxxx";
SqlConnection connection = new SqlConnection(connectionString);
SqlCommand command = new SqlCommand("select * from admin", connection);
SqlDataAdapter sqlDA = new SqlDataAdapter();
SqlCommandBuilder build = new SqlCommandBuilder(sqlDA);//构造SQL语句
DataSet dataSet = new DataSet();
sqlDA.SelectCommand = command;
sqlDA.Fill(dataSet);
connection.Close();
//获得DataSet
string connectionString = "Data Source=192.168.0.x;Initial Catalog=xxxx;User ID=xxxx;Password=xxxxx";
SqlConnection connection = new SqlConnection(connectionString);
SqlCommand command = new SqlCommand("select * from admin", connection);
SqlDataAdapter sqlDA = new SqlDataAdapter();
SqlCommandBuilder build = new SqlCommandBuilder(sqlDA);//构造SQL语句
DataSet dataSet = new DataSet();
sqlDA.SelectCommand = command;
sqlDA.Fill(dataSet);
connection.Close();
追问
不是的。ado我是知道的。。还是谢啦。。。
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询