If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > Running db2 commands from application

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 09-21-06, 06:40
dhuygu dhuygu is offline
Registered User
 
Join Date: Sep 2006
Posts: 20
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?
Reply With Quote
  #2 (permalink)  
Old 09-21-06, 08:00
singhipst singhipst is offline
Registered User
 
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 !!**
Reply With Quote
  #3 (permalink)  
Old 09-21-06, 09:13
dhuygu dhuygu is offline
Registered User
 
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
Reply With Quote
  #4 (permalink)  
Old 09-22-06, 00:20
singhipst singhipst is offline
Registered User
 
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 !!**
Reply With Quote
  #5 (permalink)  
Old 09-22-06, 02:46
dhuygu dhuygu is offline
Registered User
 
Join Date: Sep 2006
Posts: 20
thank you very much..
I created new database from my application.
Reply With Quote
  #6 (permalink)  
Old 09-22-06, 03:14
dhuygu dhuygu is offline
Registered User
 
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...
Reply With Quote
  #7 (permalink)  
Old 09-22-06, 04:56
singhipst singhipst is offline
Registered User
 
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 !!**
Reply With Quote
  #8 (permalink)  
Old 09-24-06, 14:59
Peter.Vanroose Peter.Vanroose is offline
Registered User
 
Join Date: Sep 2004
Location: Belgium
Posts: 1,079
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/
Reply With Quote
  #9 (permalink)  
Old 09-27-06, 08:14
dhuygu dhuygu is offline
Registered User
 
Join Date: Sep 2006
Posts: 20
Quote:
(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..
Reply With Quote
  #10 (permalink)  
Old 09-27-06, 11:41
Peter.Vanroose Peter.Vanroose is offline
Registered User
 
Join Date: Sep 2004
Location: Belgium
Posts: 1,079
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/
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On