我正在尝试做一个返回数据集的方法,但连接字符串不起作用。
我试过这个:
public DataSet list()
{
// First Create a New Connection
System.Data.SqlClient.SqlConnection sqlConnection1 = new System.Data.SqlClient.SqlConnection();
// Now Pass a Connection String To the Connection
sqlConnection1.ConnectionString = "Data Source=mysite.com.br;User ID=admin_devr;Password=123456;Initial Catalog="rave_dbteste" providerName="System.Data.OleDb";
// Now the Select statement you want to run
string select = "select * from table";
// Create an Adapter
SqlDataAdapter da = new SqlDataAdapter(select, sqlConnection1);
// Create a New DataSet
DataSet ds = new DataSet();
// Fill The DataSet With the Contents of the Stock Table
da.Fill(ds, "cdestacionamento");
// Now Return ds which is a DataSet
return (ds);
}
怎么了?