问题如下: 有必要将值从“select”返回到参数,但“ADO.NET”的提供程序会出错。在“PostgreSQL”中,值返回到参数中(没有指定什么,但只是按顺序),在“MsSQL”中,有必要通过@“选择”我需要变量的位置。如何在“Hana”中做到这一点?搜索没有提供信息(有必要从请求中返回值,而不是从过程中返回)。 这就是错误的样子 Provider Error
这是代码
string sql = @"select id, json from pk5_app where kind = 'form' and code = 'mycode'";
string cnStr = AppDomain.CurrentDomain.GetData("cnStr") as string;//Connection string here!
int ResultInfo=-1;
HanaParameter[] haparam = new HanaParameter[] {
new HanaParameter() { ParameterName ="id", HanaDbType= HanaDbType.Integer, Direction=ParameterDirection.Output},
new HanaParameter() { ParameterName ="json", HanaDbType= HanaDbType.NVarChar, Size=50, Direction=ParameterDirection.Output}
};
HanaConnection dbCnnHa = new HanaConnection(cnStr);
dbCnnHa.Open();
HanaTransaction trn = dbCnnHa.BeginTransaction(IsolationLevel.ReadCommitted);
using (dbCnnHa)
{
HanaCommand sqlCmd = new HanaCommand(sql, dbCnnHa, trn);
sqlCmd.Parameters.AddRange(haparam);
ResultInfo = sqlCmd.ExecuteNonQuery();
if (param != null && param.Length > 0)
trn.Commit();
}
答案 0 :(得分:0)
我遭受了很长时间,但我做了一个例子 - 现在一切似乎都很正常。
string sql = @"do (OUT id integer=>?) begin select 5 into id from dummy; end;";
string cnStr = "";//Connection string
int ResultInfo = -1;
HanaParameter haparam = new HanaParameter {
ParameterName ="id", HanaDbType= HanaDbType.Integer, Direction=ParameterDirection.Output
};
HanaConnection dbCnnHa = new HanaConnection(cnStr);
dbCnnHa.Open();
HanaTransaction trn = dbCnnHa.BeginTransaction(IsolationLevel.ReadCommitted);
using (dbCnnHa)
{
HanaCommand sqlCmd = new HanaCommand(sql, dbCnnHa, trn);
sqlCmd.Parameters.Add(haparam);
ResultInfo = sqlCmd.ExecuteNonQuery();
trn.Commit();
}