当前位置: 代码迷 >> ASP.NET >> 把access的处理函数 换成sql server2005?该怎么处理
  详细解决方案

把access的处理函数 换成sql server2005?该怎么处理

热度:3805   发布时间:2013-02-25 00:00:00.0
把access的处理函数 换成sql server2005?
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...
  相关解决方案