錯誤資訊如下:
SqlCommand.DeriveParameters failed because the SqlCommand.CommandText property value is an invalid multipart name "SELECT * from tableA", the current limit of "4" is insufficient。
錯誤原因:
使用Enterprise Library進行資料庫操作時,如果直接使用sql 語句而非預存程序,一定要用重載方法:
_db.ExecuteDataSet(CommandType type,String sql)
而不是:
public virtual DataSet ExecuteDataSet(string storedProcedureName,params Object[] parameterValues)
詳細介紹:點擊開啟連結
或者通過sql,擷取到DbCommand,再執行:
ExecuteDataSet重載方法如下:
Database.ExecuteDataSet Method (DbCommand)
public virtual DataSet ExecuteDataSet(DbCommand command)
Database.ExecuteDataSet Method (CommandType, String)
public virtual DataSet ExecuteDataSet(CommandType commandType,string commandText)
Database.ExecuteDataSet Method (DbCommand, DbTransaction)
public virtual DataSet ExecuteDataSet(DbCommand command,DbTransaction transaction)
Database.ExecuteDataSet Method (String, Object[])
public virtual DataSet ExecuteDataSet(string storedProcedureName,params Object[] parameterValues)
Database.ExecuteDataSet Method (DbTransaction, CommandType, String)
public virtual DataSet ExecuteDataSet(DbTransaction transaction,CommandType commandType,string commandText)
Database.ExecuteDataSet Method (DbTransaction, String, Object[])
public virtual DataSet ExecuteDataSet(DbTransaction transaction,string storedProcedureName,params Object[] parameterValues)
以上就是SqlCommand.DeriveParameters failed的內容,更多相關內容請關注topic.alibabacloud.com(www.php.cn)!