- C# code
public static DataSet ExecuteDataSet(CommandType commandType, string procedureName) { using (OleDbConnection connection = new OleDbConnection()) { connection.ConnectionString = ConnectionString; OleDbCommand command = new OleDbCommand(); command.CommandText = procedureName; command.CommandType = commandType; command.Connection = connection; connection.Open(); OleDbDataAdapter adapter = new OleDbDataAdapter(); adapter.SelectCommand = command; DataSet dataSet = new DataSet(); adapter.Fill(dataSet); connection.Close(); connection.Dispose(); return dataSet; } }
刚开始是用access,现在用的sql server2005,上述代码如何改?
------解决方案--------------------------------------------------------
- C# code
public static DataSet ExecuteDataSet(CommandType commandType, string procedureName) { using (SqlConnection connection = new SqlConnection()) { connection.ConnectionString = ConnectionString; SqlCommand command = new SqlCommand (); command.CommandText = procedureName; command.CommandType = commandType; command.Connection = connection; connection.Open(); SqlDataAdapter adapter = new SqlDataAdapter(); adapter.SelectCommand = command; DataSet dataSet = new DataSet(); adapter.Fill(dataSet); connection.Close(); connection.Dispose(); return dataSet; } }
------解决方案--------------------------------------------------------
基本是ole的换成sql 开头的
http://www.cnblogs.com/icedog/archive/2010/08/12/1798495
------解决方案--------------------------------------------------------
OleDbConnection 改 SqlDBConnection
------解决方案--------------------------------------------------------
using system.data.sqlclient...