Results 1 to 10 of 10
  1. #1
    Join Date
    Sep 2006
    Posts
    20

    Unanswered: Running db2 commands from application

    How can I run db2 commands from .net application?
    rahul_s80 suggested to look \IBM\SQLLIB\samples\.NET
    I looked these folders but couldnt find anything.

    I want to create a new database from my application.Then I want to copy a table from the database on server to my new local database.I'm using db2 v8.
    By using admin_cmd() I can only export the files.But I couldnt find any procedure to create new database from my application and then import files to my new database.
    Can you help me please?

  2. #2
    Join Date
    Jul 2006
    Location
    Bangalore
    Posts
    57
    You can use this i tried it for VB 6.0

    Create one text file as test and write
    !DB2 CREATE DATABASE TEST !
    Then
    create one batch batch1 with followin command
    db2cw db2 -td! -f <textfile path which you have created(test)>

    Then Create one more batch file batch2 which contains followin command
    DB2CW @<first batch file path (batch1)>

    and now finaly you can call batch2 from dot net then it will create database

    i hope it will be helpfull for you...................
    Ritesh Kumar Singh
    IBM Certified DB2 DBA for LUW
    **Knowledge Is Theft If Not Shared !!**

  3. #3
    Join Date
    Sep 2006
    Posts
    20

    error

    I created test.txt file.
    then run->cmd and wrote
    db2cw db2 -td! -f D:\Documents and Settings\db2admin\My Documents\test.txt
    then it says You cannot specify both an input file and a command when invoking the Command Line Processor.What does it mean? I have never created batch files before.
    is it possible to use batch file for import command?
    my english is not good enough.sorry for this..
    thanks

  4. #4
    Join Date
    Jul 2006
    Location
    Bangalore
    Posts
    57
    For creating batch file just create txt file write command and then save it with extention bat eg
    create batch1.txt after writing the file save it as batch1.bat this is your batch file if you click on this file automaticlly it will execute command whichwas written inside the batch file.
    Ritesh Kumar Singh
    IBM Certified DB2 DBA for LUW
    **Knowledge Is Theft If Not Shared !!**

  5. #5
    Join Date
    Sep 2006
    Posts
    20
    thank you very much..
    I created new database from my application.

  6. #6
    Join Date
    Sep 2006
    Posts
    20

    Import

    Have you got any idea about importing ?
    I can export the database table by call sysproc.admin_cmd('export .......').
    Now with the help of you I created a new database from my application.
    But now I want to import the file to my new database...
    thanks...

  7. #7
    Join Date
    Jul 2006
    Location
    Bangalore
    Posts
    57
    use import command to load data in you table from file
    Ritesh Kumar Singh
    IBM Certified DB2 DBA for LUW
    **Knowledge Is Theft If Not Shared !!**

  8. #8
    Join Date
    Sep 2004
    Location
    Belgium
    Posts
    1,126
    Quote Originally Posted by dhuygu
    db2cw db2 -td! -f D:\Documents and Settings\db2admin\My Documents\test.txt
    *** You cannot specify both an input file and a command when invoking the Command Line Processor.
    The reason for this error message is that the file name contains spaces: db2 thinks the file is just called "D:\Documents" so it interprets "and" , "Settings\db2admin\My" and "Documents\test.txt" as three separate arguments.

    To circumvent this behaviour, quote the filename argument:
    Code:
    db2cw db2 -td! -f "D:\Documents and Settings\db2admin\My Documents\test.txt"
    (I'm assuming you use cmd.exe as command line interpreter and not e.g. bash.)
    Alternatively, first chdir to D:\Documents and Settings\db2admin\My Documents and issue the command with the shorter argument -f test.txt
    --_Peter Vanroose,
    __IBM Certified Database Administrator, DB2 9 for z/OS
    __IBM Certified Application Developer
    __ABIS Training and Consulting
    __http://www.abis.be/

  9. #9
    Join Date
    Sep 2006
    Posts
    20
    (I'm assuming you use cmd.exe as command line interpreter and not e.g. bash.)
    Alternatively, first chdir to D:\Documents and Settings\db2admin\My Documents and issue the command with the shorter argument -f test.txt
    Can you explain it step by step.I'm new.
    How can I send command to cmd.exe?
    I will writes command again into test.txt file.Then What will I do?
    I will be very happr if you give more info..
    thanks..

  10. #10
    Join Date
    Sep 2004
    Location
    Belgium
    Posts
    1,126
    Did you try the following?
    - Click "Start", then "Run".
    - In the window, type "cmd.exe" and press enter.
    - In the new window, type
    db2cw db2 -td! -f "D:\Documents and Settings\db2admin\My Documents\test.txt"
    (on a single line)
    - Alternatively, type the following three commands:
    D:
    cd \Documents and Settings\db2admin\My Documents
    db2cw db2 -td! -f test.txt
    --_Peter Vanroose,
    __IBM Certified Database Administrator, DB2 9 for z/OS
    __IBM Certified Application Developer
    __ABIS Training and Consulting
    __http://www.abis.be/

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •