Question

I have below oracleCommand and like to change below but having error...doesn't except my +item+ and + txtSrcUserID.Text.ToUpper() + . in the oracleCommand. How can I add them to my command?

Original

foreach (string Items in listBox39.Items)
                    {
                        using (OracleCommand crtCommand = new OracleCommand(@"SELECT  REGEXP_REPLACE ( REPLACE ( dbms_metadata.get_ddl ('PROCEDURE', 'HELL_'), '""USER1"".'),'^\s+', NULL, 1, 0, 'm') FROM dual", conn1))
                        {

                        }
                    }

I like to make similar to below

foreach (string Items in listBox39.Items)
                        {
                            using (OracleCommand crtCommand = new OracleCommand(@"SELECT  REGEXP_REPLACE ( REPLACE ( dbms_metadata.get_ddl ('PROCEDURE', '+ Items +'), '"" + txtSrcUserID.Text.ToUpper() + "".'),'^\s+', NULL, 1, 0, 'm') FROM dual", conn1))
                            {

                            }
                        }
Était-ce utile?

La solution

foreach (string Items in listBox39.Items)
{
    using (OracleCommand crtCommand = new OracleCommand(@"SELECT  REGEXP_REPLACE ( REPLACE ( dbms_metadata.get_ddl ('PROCEDURE', '" + Items + @"'), '""" + txtSrcUserID.Text.ToUpper() + @""".'),'^\s+', NULL, 1, 0, 'm') FROM dual", conn1))
    {

    }
}

But as @SLaks suggested in his comment, better to use parameters:

OracleCommand.Parameters

OracleCommand SQL Parameters Binding

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top