Topic
  • 4 replies
  • Latest Post - ‏2013-05-31T01:57:01Z by JiuPang
SystemAdmin
SystemAdmin
3105 Posts

Pinned topic how to invoke CLP command thru .net program using db2 connect api

‏2011-10-31T21:47:48Z |
I am trying to invoke the following command thru my .net program

CONNECT TO <database> USER <userid> USING <password>
NEW <new_password> CONFIRM <new_password>

sample code:

string commandText = "CONNECT TO DB2FLF USER myid USING pwd1 NEW pwd2 CONFIRM pwd2";
DB2Connection conn = new DB2Connection(connectionString);
conn.Open();
DB2Command cmd = new DB2Command(commandText, conn);
cmd.CommandType = CommandType.Text;
cmd.ExecuteNonQuery();
conn.Close();

it always throws this error - "ERROR 37000 IBM CLI0118E Invalid SQL syntax. SQLSTATE=37000".

the command works fine from control center command editor though !
Updated on 2011-11-03T15:13:48Z at 2011-11-03T15:13:48Z by SystemAdmin
  • SystemAdmin
    SystemAdmin
    3105 Posts

    Re: how to invoke CLP command thru .net program using db2 connect api

    ‏2011-11-03T15:13:48Z  
    you can't do that
    you can only run SQL statement using the .net provider

    in order to run clp commands you can use the admin_cmd stored procedure but it does not support password change
    in order to change a password from code, you will have to use this
    http://publib.boulder.ibm.com/infocenter/db2luw/v9r7/topic/com.ibm.db2.luw.apdv.api.doc/doc/r0001715.html
  • JiuPang
    JiuPang
    2 Posts

    Re: how to invoke CLP command thru .net program using db2 connect api

    ‏2013-05-08T09:45:40Z  
    you can't do that
    you can only run SQL statement using the .net provider

    in order to run clp commands you can use the admin_cmd stored procedure but it does not support password change
    in order to change a password from code, you will have to use this
    http://publib.boulder.ibm.com/infocenter/db2luw/v9r7/topic/com.ibm.db2.luw.apdv.api.doc/doc/r0001715.html

    Hi,

    I know it is after 2 years and yet i was still asking the almost same question here.

    adm_cmd stored procedure manage to invoke some of the CLP command, I would like to know how to call the "List db Directory" from stored procedure.

    I would like to list all the database in one instance from c# application. I had search through the web but so far i was almost give up. 

    Can you please let me know besides "List DB Directory", is there any select statement to list all the database in one instance?

    Your help is really appreciated.

     

    Thanks.

     

  • Kalexin
    Kalexin
    1 Post

    Re: how to invoke CLP command thru .net program using db2 connect api

    ‏2013-05-31T00:16:18Z  
    • JiuPang
    • ‏2013-05-08T09:45:40Z

    Hi,

    I know it is after 2 years and yet i was still asking the almost same question here.

    adm_cmd stored procedure manage to invoke some of the CLP command, I would like to know how to call the "List db Directory" from stored procedure.

    I would like to list all the database in one instance from c# application. I had search through the web but so far i was almost give up. 

    Can you please let me know besides "List DB Directory", is there any select statement to list all the database in one instance?

    Your help is really appreciated.

     

    Thanks.

     

    List DB Directory is a DB2 LUW command. Are you connected to a DB2 LUW or DB2 for z/OS?

  • JiuPang
    JiuPang
    2 Posts

    Re: how to invoke CLP command thru .net program using db2 connect api

    ‏2013-05-31T01:57:01Z  
    • Kalexin
    • ‏2013-05-31T00:16:18Z

    List DB Directory is a DB2 LUW command. Are you connected to a DB2 LUW or DB2 for z/OS?

    Hi Kalexin,

    Im connected to DB2 LUW. Do you have any solution for this problems?

     

    Thanks a lot.