代码:public int InsertDBBySend(string branchId,string operatorA,out string fileName)
{
int result = -1;
OdbcParameter[] pars = new OdbcParameter[] { new OdbcParameter("@branch_id",OdbcType.VarChar,11),
new OdbcParameter("@operator", OdbcType.VarChar,10),
new OdbcParameter("@error_msg",OdbcType.VarChar,100),
new OdbcParameter("@file_name",OdbcType.VarChar,60),
new OdbcParameter("@return",SqlDbType.Int)
};
pars[0].Value = "SMBC";//branchId
pars[1].Value = "SYS";//operatorA
pars[2].Direction = ParameterDirection.Output;
pars[3].Direction = ParameterDirection.Output;
// pars[4].Value = -1;
pars[4].Direction = ParameterDirection.ReturnValue;
ArrayList list = new ArrayList();
result = Convert.ToInt32(dbHelp.ExecuteQueryForScalar("sp_CMSCPGGenMsg", pars,out list));
}
public object ExecuteQueryForScalar(string strSql, OdbcParameter[] parameters, out ArrayList parasList)
{
object result = -1;
try
{
OdbcCommand sqlCmd = PrepareCommand(CommandType.StoredProcedure, strSql, parameters);
parasList = new ArrayList(); sqlCmd.ExecuteNonQuery();
result =sqlCmd.Parameters["@return"].Value;
for (int i = 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 (Exception ex)
{
conn.Close();
throw ex;
}
finally
{
//不能关闭数据库
}
return result;
}protected OdbcCommand PrepareCommand(CommandType cmdType, string cmdText, params OdbcParameter[] cmdParms)
{ //数据库连接对象
if (conn == null)
conn = new OdbcConnection(conn_string);
try
{
OdbcCommand cmd;
//数据库连接状态
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 (OdbcParameter parm in cmdParms)
{
cmd.Parameters.Add(parm);
}
}
return cmd;
}
catch (Exception ex)
{
conn.Close();
}
return null; }报ERROR [HY000] [INTERSOLV][ODBC SQL Server driver][SQL Server]ct_describe(): user api layer: external error: An illegal value of 3 given for parameter item.
错误,我急死了,调了一天,还是没解决!
请高手指点
{
int result = -1;
OdbcParameter[] pars = new OdbcParameter[] { new OdbcParameter("@branch_id",OdbcType.VarChar,11),
new OdbcParameter("@operator", OdbcType.VarChar,10),
new OdbcParameter("@error_msg",OdbcType.VarChar,100),
new OdbcParameter("@file_name",OdbcType.VarChar,60),
new OdbcParameter("@return",SqlDbType.Int)
};
pars[0].Value = "SMBC";//branchId
pars[1].Value = "SYS";//operatorA
pars[2].Direction = ParameterDirection.Output;
pars[3].Direction = ParameterDirection.Output;
// pars[4].Value = -1;
pars[4].Direction = ParameterDirection.ReturnValue;
ArrayList list = new ArrayList();
result = Convert.ToInt32(dbHelp.ExecuteQueryForScalar("sp_CMSCPGGenMsg", pars,out list));
}
public object ExecuteQueryForScalar(string strSql, OdbcParameter[] parameters, out ArrayList parasList)
{
object result = -1;
try
{
OdbcCommand sqlCmd = PrepareCommand(CommandType.StoredProcedure, strSql, parameters);
parasList = new ArrayList(); sqlCmd.ExecuteNonQuery();
result =sqlCmd.Parameters["@return"].Value;
for (int i = 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 (Exception ex)
{
conn.Close();
throw ex;
}
finally
{
//不能关闭数据库
}
return result;
}protected OdbcCommand PrepareCommand(CommandType cmdType, string cmdText, params OdbcParameter[] cmdParms)
{ //数据库连接对象
if (conn == null)
conn = new OdbcConnection(conn_string);
try
{
OdbcCommand cmd;
//数据库连接状态
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 (OdbcParameter parm in cmdParms)
{
cmd.Parameters.Add(parm);
}
}
return cmd;
}
catch (Exception ex)
{
conn.Close();
}
return null; }报ERROR [HY000] [INTERSOLV][ODBC SQL Server driver][SQL Server]ct_describe(): user api layer: external error: An illegal value of 3 given for parameter item.
错误,我急死了,调了一天,还是没解决!
请高手指点
解决方案 »
- 在C#中用代码实现获取VSS中的文件列表,长传和下载文件
- 如何通过C#识别WORD表格某个格子内的内容是普通文本,还是复杂内容(可能有公式、图片、表格)?
- 怎样做重载
- 新人又来提问咯``- -大虾们快快出手吧``
- 关于Remoting!!!!!!
- e.Cancel = this.CheckUpdates();
- 求查找下一个TreeNode的思路!!!
- 如何做出像Visual Studio .NET 自带的组件一样的组件!!!!!!
- ftp的源程序,欢迎指教!
- 急啊!如何实现创建一个数据库create database?
- 如何做到C# Treeview加载节点选中状态
- 请问C#,如何实现这个效果?
private string getDuoGeWenHao(int number)
{
if (number < 1) return "";
string str = "?";
for (int i = 1; i < number; i++)
str += ",?";
return str;
}