SitePoint Sponsor

User Tag List

Results 1 to 7 of 7

Hybrid View

  1. #1
    SitePoint Member
    Join Date
    Dec 2012
    Location
    Sweden
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How can i copy data from one database to another

    For example
    db1.mdb copy everything from a filed to database db2.

    Im newbee and nedd how to setup the connectionbetween them too

  2. #2
    SitePoint Enthusiast
    Join Date
    Aug 2011
    Location
    OH, USA
    Posts
    72
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    in simple case ( i assume you on the same server)

    insert into db2.dbo.Table1
    select * from db1.dbo.table1

  3. #3
    SitePoint Member
    Join Date
    Dec 2012
    Location
    Sweden
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    yes it should be simple btw thx for the answer
    My script looks like this ... it works fine but it only copy the first record from the first databese to the second database

    <%

    Set Conn1=Server.CreateObject("ADODB.Connection")
    conn1.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & server.MapPath ("/scriptarkiv/nopho_conn/database/nopho_01.mdb")
    set rs = conn1.execute("Select Ballot_emailgroup FROM nophousers")
    tempfield1 = rs("Ballot_emailgroup")
    rs.close
    set rs= nothing
    conn1.close
    set conn1 = nothing


    set conn2=Server.CreateObject("ADODB.Connection")
    conn2.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & server.MapPath ("/member_pages/ballot/vote.mdb")
    conn2.execute "Insert into data (email) Values ('" & tempfield1 & "')"

    %>

  4. #4
    SitePoint Enthusiast
    Join Date
    Aug 2011
    Location
    OH, USA
    Posts
    72
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    In this case you need to modify you code

    <%

    Set Conn1=Server.CreateObject("ADODB.Connection")
    conn1.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & server.MapPath ("/scriptarkiv/nopho_conn/database/nopho_01.mdb")

    set conn2=Server.CreateObject("ADODB.Connection")
    conn2.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & server.MapPath ("/member_pages/ballot/vote.mdb")

    set rs = conn1.execute("Select Ballot_emailgroup FROM nophousers")
    do while not rs.EOF


    conn2.execute "Insert into data (email) Values ('" & rs("Ballot_emailgroup") & "')"

    rs.MoveNext
    loop

    rs.close
    set rs= nothing
    conn1.close
    set conn1 = nothing

    %>

  5. #5
    SitePoint Member
    Join Date
    Dec 2012
    Location
    Sweden
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thx gk53. realy appreciate your help
    Now it works fine

  6. #6
    SitePoint Member
    Join Date
    Dec 2012
    Location
    Sweden
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    And if i want som kind off errorhandler to the same script, if empty record move to next record without stop.
    Is that posible


Bookmarks

Posting Permissions

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