Create DB2 Database When Application Runs First Time Development in Vb.net

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • KishorDhembare
    New Member
    • Apr 2010
    • 9

    Create DB2 Database When Application Runs First Time Development in Vb.net

    Hi Everybady

    I Want To Create New Database When My Application Starts First Time My Application Developed In Vb.net


    I Get The Error When I Run Command which I Have Command Is Like.

    Code:
     Dim file As FileInfo = New FileInfo(Path.GetFullPath("TextFile1.txt"))
    Dim backupScript As String = file.OpenText.ReadToEnd()
    Dim strCommand As String = backupScript
    'Dim strConnection As String = "Driver={IBM DB2 ODBC DRIVER};Database=evaidya;Port=50000;Protocol=TCPIP ;Uid=db2Admin;Pwd=tatya;"
    Dim strConnection As String = "Provider=IBMDADB2;DSN=MyName;UID=MyID;PWD=MyPass; "
    
    
    Dim DBConnection As OleDbConnection = New OleDbConnection(strConnection)
    Dim cmdSoftware As New OleDbCommand(backupScript, DBConnection)
    DBConnection.Open()
    The File TextFile1.txt contain the command For database creation.....
    is :

    CREATE DATABASE Temp AUTOMATIC STORAGE YES ON 'C:\' DBPATH ON 'C:\' USING CODESET IBM-1252 TERRITORY US COLLATE USING SYSTEM PAGESIZE 4096;


    The Error occurred is as :

    [DB2/NT] SQL0104N An unexpected token "CREATE DATABASE temp AUTOMATIC STORAGE YES" was found following "BEGIN-OF-STATEMENT". Expected tokens may include: "<values>". SQLSTATE=42601


    This Command Runs on DB2 command editor.....But without get connected to other database....if we first connect to any database and then run this command then it not run....it gives an error...
Working...