欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  数据库

mysql-VS2010+MYSQL 存儲過程調用出錯

程序员文章站 2023-12-31 13:20:52
...
mysqlvisual studio 2010c#

VS2010+MYSQL,
連接字符串
server=**.***.***.**; user id=*; password=*; database=*; pooling=false;charset=gb2312
和Database=*;Data Source=**.***.***.**;User Id=*;Password=*;pooling=false;CharSet=utf8;port=3306
都試過,只要存儲過程查詢結果一用到case when,ifnull,CONCAT這些去處理,那麼在工具中調用該
存儲過程(CALL TEST())沒問題,但是在c#代碼中就報錯,錯誤內容為:指定的索引鍵不在字典中。
請教下大神們這是咋回事呢
於 System.Collections.Generic.Dictionary`2.get_Item(TKey key)
於 MySql.Data.MySqlClient.CharSetMap.GetChararcterSet(DBVersion version, String CharSetName)
於 MySql.Data.MySqlClient.NativeDriver.GetFieldMetaData41()
於 MySql.Data.MySqlClient.NativeDriver.GetFieldMetaData()
於 MySql.Data.MySqlClient.NativeDriver.ReadColumnMetadata(Int32 count)
於 MySql.Data.MySqlClient.MySqlDataReader.NextResult()
於 MySql.Data.MySqlClient.MySqlCommand.ExecuteReader(CommandBehavior behavior)
於 MySql.Data.MySqlClient.MySqlCommand.ExecuteDbDataReader(CommandBehavior behavior)
於 System.Data.Common.DbCommand.System.Data.IDbCommand.ExecuteReader(CommandBehavior behavior)
於 System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
於 System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
於 System.Data.Common.DbDataAdapter.Fill(DataSet dataSet)
DataSet ds = new DataSet();
MySqlCommand cmd = new MySqlCommand(stroeProcedure, Connection);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddRange(values);
MySqlDataAdapter da = new MySqlDataAdapter(cmd);
da.Fill(ds);
connection.Close();

                            在da.Fill(ds)這就報錯了。。。

SQL 如下,只要用到case when和concat,代碼調用時就報這個錯誤
SELECT C.ORDER_NO ,-- CONCAT(C.ORDER_CANCEL_REASON,'') AS aa-- ,case when C.status=1 then '申請取消'
else 'N/A'
end AS "status"
FROM AREA_T A,GROUP_BUYING_T B,ORDER_T C,PAY_TYPE_T D
WHERE A.AREA_ID = C.AREA_ID
AND B.GROUP_BUYING_ID = C.GROUP_BUYING_ID
AND C.PAY_TYPE_ID=D.PAY_TYPE_ID
AND C.ORDER_NO=V_ORDER_NO

上一篇:

下一篇: