问题描述
代码:publicintInsertDBBySend(stringbranchId,stringoperatorA,outstringfileName){intresult=-1;OdbcParameter[]pars=newOdbcParameter[]{newOdbcParameter("@branch_id",OdbcType.VarChar,11),newOdbcParameter("@operator",OdbcType.VarChar,10),newOdbcParameter("@error_msg",OdbcType.VarChar,100),newOdbcParameter("@file_name",OdbcType.VarChar,60),newOdbcParameter("@return",SqlDbType.Int)};pars[0].Value="SMBC";//branchIdpars[1].Value="SYS";//operatorApars[2].Direction=ParameterDirection.Output;pars[3].Direction=ParameterDirection.Output;//pars[4].Value=-1;pars[4].Direction=ParameterDirection.ReturnValue;ArrayListlist=newArrayList();result=Convert.ToInt32(dbHelp.ExecuteQueryForScalar("sp_CMSCPGGenMsg",pars,outlist));}publicobjectExecuteQueryForScalar(stringstrSql,OdbcParameter[]parameters,outArrayListparasList){objectresult=-1;try{OdbcCommandsqlCmd=PrepareCommand(CommandType.StoredProcedure,strSql,parameters);parasList=newArrayList();sqlCmd.ExecuteNonQuery();result=sqlCmd.Parameters["@return"].Value;for(inti=0;i<sqlCmd.Parameters.Count;i++){if(sqlCmd.Parameters[i].Direction==ParameterDirection.Output||sqlCmd.Parameters[i].Direction==ParameterDirection.InputOutput)parasList.Add(sqlCmd.Parameters[i].Value);}}catch(Exceptionex){conn.Close();throwex;}finally{//不能关闭数据库}returnresult;}protectedOdbcCommandPrepareCommand(CommandTypecmdType,stringcmdText,paramsOdbcParameter[]cmdParms){//数据库连接对象if(conn==null)conn=newOdbcConnection(conn_string);try{OdbcCommandcmd;//数据库连接状态if(conn.State!=ConnectionState.Open)conn.Open();//命令初始话cmd=conn.CreateCommand();//cmd.Connection=conn;cmd.CommandText="exec"+cmdText+""+getDuoGeWenHao(cmdParms.Length);//是否起事物if(trans!=null)cmd.Transaction=trans;//命令类型cmd.CommandType=cmdType;//传入命令参数if(cmdParms!=null){foreach(OdbcParameterparmincmdParms){cmd.Parameters.Add(parm);}}returncmd;}catch(Exceptionex){conn.Close();}returnnull;}
报ERROR[HY000][INTERSOLV][ODBCSQLServerdriver][SQLServer]ct_describe():userapilayer:externalerror:Anillegalvalueof3givenforparameteritem.错误,我急死了,调了一天,还是没解决!请高手指点
解决方案
解决方案二:
自己订,有谁能帮忙看看啊!!!
解决方案三:
补充下,刚刚里面还有个方法,继续贴!privatestringgetDuoGeWenHao(intnumber){if(number<1)return"";stringstr="?";for(inti=1;i<number;i++)str+=",?";returnstr;}