Hi Mehmet,
Below is part of my working C# .NET code to drop, create and run the very simple(simplest) stored procedure. You can follow the below constructs for your stored procedure operations.
HTH
try
{
thisTest.testLog.LogLine("Set CommandType to StoredProcedure");
thisTest.defaultCmd.CommandType = CommandType.StoredProcedure;
thisTest.testLog.LogLine("Set CommandText");
thisTest.defaultCmd.CommandText = "noInParams";
thisTest.testLog.LogLine("Execute Procedure");
thisTest.defaultCmd.ExecuteReader();
}
catch(IfxException ie)
{
thisTest.CheckErrors(ie);
}
try
{
thisTest.testLog.LogLine("Dropping procedure noInParams");
thisTest.defaultCmd.CommandText = "DROP PROCEDURE noInParams";
thisTest.defaultCmd.ExecuteNonQuery();
}
catch
{
//handle any exception here
}
thisTest.testLog.LogLine("Creating procedure noInParams");
thisTest.defaultCmd.CommandText = "CREATE PROCEDURE noInParams(); END PROCEDURE";
thisTest.defaultCmd.ExecuteNonQuery();
Thanks
-Shesh
------------------------------
Sheshnarayan Agrawal
------------------------------
Original Message:
Sent: Fri June 04, 2021 03:30 PM
From: Mehmet Padonci
Subject: How can I create stored procedures from c# code that uses .NET provider?
Hi all:
Through the .NET provider, my c# program can successfully create tables, constraints, and indices. But whenever I try to create a stored procedure, I get error 42000 'A syntax error occurred'. However, if I copy and paste the text assigned to the .CommandText property, into dbaccess, then it creates the procedure successfully. This occurs for any stored procedure, not just for some specific one. Are there any settings that have to be adjusted on the connection or on the IfxCommand object, to allow it to create stored procedures?
Since my program is 32 bit, I am using clientsdk.4.10.TC14.windows86.zip provider, and my server is 14.10FC4.
Thanks all!
#Informix