Hi Girish,


Try this:

    ODBCConnection      oDBCConnection;
    LoginProperty       loginProperty;
    Statement           statement;
    ;

    // Initialize Connection
    loginProperty   = new LoginProperty();
    loginProperty.setDSN('SQLBucket'); // DSN Name - CHANGE THIS!
    loginProperty.setUsername("sa"); // user name
    loginProperty.setDatabase('<YourDbName>'); // CHANGE THIS!
    loginProperty.setServer("192.168.200.112"); // SERVER - CHANGE THIS!

    loginProperty.setPassword(""); // password - MIGHT CHANGE THIS!

    // Create Connection Object
    ODBCConnection  = new ODBCConnection(loginProperty);
    statement       = oDBCConnection.createStatement();

    // Execute update Query
    statement.executeUpdate("Insert into ZIPCODE SELECT * from [ax30].[dbo].[ZIPCODE]"); // CHANGE "ax30" - this is the db you read from.

The above works for me.


//Lars



-----Original Message-----
From: Girish Bhatkal [mailto:[EMAIL PROTECTED]
Sent: 26. juli 2004 15:22
To: [EMAIL PROTECTED]
Subject: RE: [development-axapta] Re: insert records SQL table outside axapta


Hi Lars,

   i did write a job to test but could not copy the data. the job is as
copied below. the table name is "TravellersAwaitPart_ALL" . can you let me
know where am i going wrong ?

    thanks

static void Job31(Args _args)

{

    ODBCConnection      oDBCConnection;

    LoginProperty       loginProperty;

    Statement           statement;

    ;

      Company = curext();

    // Initialize Connection

    loginProperty   = new LoginProperty();

    loginProperty.setDSN('BMSDSN_FM'); // DSN Name

    loginProperty.setUsername("sa"); // user name

    loginProperty.setPassword("test"); // password

    // Create Connection Object

    ODBCConnection  = new ODBCConnection(loginProperty);

    statement       = oDBCConnection.createStatement();

      // connection



    // Execute Query

    statement.executeQuery("Insert into TravellersAwaitPart_ALL SELECT *
[database].dbo.[TravellersAwaitPart_ALL]'");



}

  -----Original Message-----
  From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
  Sent: 26 July 2004 12:15
  To: [EMAIL PROTECTED]
  Subject: RE: [development-axapta] Re: insert records SQL table outside
axapta


  If the schemas are the same - how about something like this then:

  insert into custtable select * from [database].[dbo].[CUSTTABLE];

  You can also create a loop but this is nonsense and will take forever and
generate too much net / db traffic.

  //Lars


  -----Original Message-----
  From: Girish Bhatkal [mailto:[EMAIL PROTECTED]
  Sent: 26. juli 2004 12:58
  To: [EMAIL PROTECTED]
  Subject: RE: [development-axapta] Re: insert records SQL table outside
axapta


  Hi Soren / Jesper,

     i know this waay but this would insert only one line but i wanted to
  understand if there is a way to populate the complete set of records.
                      one way  i know to acheive this is by writing while
loop
  to get each line (from axapta table) and then keep running the sql
statement
  to insert the record in the external table one by one. Now if  in this
  axapta table while contains 5 fields and there could be around 5000
records.
  Is there any way i can populate the external table with these records in
one
  go.

  Thanks,
  Girish

    -----Original Message-----
    From: graver0206 [mailto:[EMAIL PROTECTED]
    Sent: 26 July 2004 11:07
    To: [EMAIL PROTECTED]
    Subject: [development-axapta] Re: insert records SQL table outside
axapta


    Hi Girish.

    The following code-extract inserts records into an external database
    using a ODBC connection.

    Regards,
    S�ren Graversen


        OdbcConnection              OdbcCon;
        str             query1;
        Statement S;
        ResultSet R;

        boolean updateOk;

        LoginProperty LP = new LoginProperty();

        str host = "pcsg2";
        ;

        LP.setDSN("SGMYSQL");
        LP.setServer(host);
        LP.setUsername("Myadmin");
        LP.setPassword("password");

        OdbcCon = new OdbcConnection(LP);

    // Insert package information
        query1 = strfmt("INSERT INTO FodocWebDistTable (JournalId,
    AuthId, PostedDate) VALUES ('%1', '%2', '%3')",
            replQueue.JournalId,
            authid,
            date2Str(replQueue.createdDate,321,2,3,2,3,4),
            );

        if (OdbcCon)
        {
            S = OdbcCon.createStatement();
            updateOk = S.executeUpdate(query1);
        }
        else
            error("@FOC2129");


    --- In [EMAIL PROTECTED], "Girish Bhatkal"
    <[EMAIL PROTECTED]> wrote:
    > Hi everyone,
    >
    >   whenever axapta needed to extract data from an SQL (on which
    axapta is not
    > running) then we can get the data using the process of
    > 1. initialise the connection to the external database (connect
    using ODBC)
    > 2. run the SQL statement and get the executed query data in the
    resultset
    > 3. now by using result.next() we get the records and update in the
    axapta
    > table
    >
    >  similarly now if we want to run the opposite way i.e pickup the
    data
    > (multiple records) from an axapta table and then insert these
    records in a
    > table present in a database which is not running on axapta how to
    do this?
    >           if anyone know how to achieve this please let me know.
    >
    > thanks
    >
    > Girish


          Yahoo! Groups Sponsor
                ADVERTISEMENT





  --------------------------------------------------------------------------
--
  --
    Yahoo! Groups Links

      a.. To visit your group on the web, go to:
      http://groups.yahoo.com/group/development-axapta/ <http://groups.yahoo.com/group/development-axapta/>
< http://groups.yahoo.com/group/development-axapta/ <http://groups.yahoo.com/group/development-axapta/> >

      b.. To unsubscribe from this group, send an email to:
      [EMAIL PROTECTED]

      c.. Your use of Yahoo! Groups is subject to the Yahoo! Terms of
Service.



  [Non-text portions of this message have been removed]



  Yahoo! Groups Sponsor

  ADVERTISEMENT

< http://us.ard.yahoo.com/SIG=12917rb76/M=295196.4901138.6071305.3001176/D=gr <http://us.ard.yahoo.com/SIG=12917rb76/M=295196.4901138.6071305.3001176/D=gr>
oups/S=1705006764:HM/EXP=1090926803/A=2128215/R=0/SIG=10se96mf6/* http://comp <http://comp>
anion.yahoo.com> click here

< http://us.adserver.yahoo.com/l?M=295196.4901138.6071305.3001176/D=groups/S= <http://us.adserver.yahoo.com/l?M=295196.4901138.6071305.3001176/D=groups/S=>
:HM/A=2128215/rand=209996599>


    _____

  Yahoo! Groups Links


  *      To visit your group on the web, go to:
  http://groups.yahoo.com/group/development-axapta/ <http://groups.yahoo.com/group/development-axapta/>
< http://groups.yahoo.com/group/development-axapta/ <http://groups.yahoo.com/group/development-axapta/> >


  *      To unsubscribe from this group, send an email to:
  [EMAIL PROTECTED]
<mailto:[EMAIL PROTECTED]>


  *      Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service
< http://docs.yahoo.com/info/terms/ <http://docs.yahoo.com/info/terms/> > .




  [Non-text portions of this message have been removed]


        Yahoo! Groups Sponsor
              ADVERTISEMENT





----------------------------------------------------------------------------
--
  Yahoo! Groups Links

    a.. To visit your group on the web, go to:
    http://groups.yahoo.com/group/development-axapta/ <http://groups.yahoo.com/group/development-axapta/>

    b.. To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

    c.. Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.



[Non-text portions of this message have been removed]



Yahoo! Groups Sponsor     

ADVERTISEMENT
<http://us.ard.yahoo.com/SIG=129g0irnm/M=295196.4901138.6071305.3001176/D=groups/S=1705006764:HM/EXP=1090935121/A=2128215/R=0/SIG=10se96mf6/*http://companion.yahoo.com> click here     
  <http://us.adserver.yahoo.com/l?M=295196.4901138.6071305.3001176/D=groups/S=:HM/A=2128215/rand=976517588>      


  _____ 

Yahoo! Groups Links


*      To visit your group on the web, go to:
http://groups.yahoo.com/group/development-axapta/ <http://groups.yahoo.com/group/development-axapta/>
 

*      To unsubscribe from this group, send an email to:
[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>
 

*      Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service <http://docs.yahoo.com/info/terms/> .




[Non-text portions of this message have been removed]


Yahoo! Groups Sponsor
ADVERTISEMENT
click here


Yahoo! Groups Links

Reply via email to