C# 使用sybase ASE命令运行ExecuteOnQuery()时出错
当我使用sybase提供程序sybase.AdoNet4.AseClient在C#ADO.NET中运行writetext sql命令时,出现了一个错误。我尝试了很多不同的方法,例如使用parameterindex、命名参数等。有人能帮忙吗?我在下面展示示例代码C# 使用sybase ASE命令运行ExecuteOnQuery()时出错,c#,sql,asp.net-web-api,ado.net,sybase,C#,Sql,Asp.net Web Api,Ado.net,Sybase,当我使用sybase提供程序sybase.AdoNet4.AseClient在C#ADO.NET中运行writetext sql命令时,出现了一个错误。我尝试了很多不同的方法,例如使用parameterindex、命名参数等。有人能帮忙吗?我在下面展示示例代码 AseConnection cn = new AseConnection(connection.ConnectionString); cn.Open(); //..... there is other code here that ca
AseConnection cn = new AseConnection(connection.ConnectionString);
cn.Open();
//..... there is other code here that calls a stored procedure and gets textpointer
// reference, but I am leaving it out to keep it short and simple
AseCommand cmd2 = new AseCommand("writetext mytable.column1 @textPointer @bigText", cn);
cmd2.CommandType = CommandType.Text
cmd2.Parameters.Add(new AseParameter("@textPointer", AseDbType.VarBinary, 16));
cmd2.Parameters["textPointer"].value = textPointerOut.value
cmd2.Parameters.Add(new AseParameter("@bigText", AseDbType.Text));
cmd2.Parameters["bigText"].value = bigText;
cmd2.ExecuteNonQuery();
cmd2.ExecuteNoQuery()引发异常,错误为必须声明变量@textPointer
更新:如果我尝试下面的语法,我会在'@bigText'
AseCommand cmd2 = new AseCommand("{writetext mytable.column1 @textPointer @bigText}", cn);
我太执着于向动态SQL传递参数了。无需使用命名参数。使用动态sql,我必须执行以下操作:
我没有使用Sybase和Asecommand…,但是,在为参数设置值时,您可能不需要使用@。@Isaid我将尝试您的建议。谢谢。@Isaid根据您的建议进行了更改。我仍然得到同样的错误。