Results 1 to 11 of 11

Thread: move record {Resolved}

  1. #1

    Thread Starter
    Lively Member splazz's Avatar
    Join Date
    Sep 2002
    Posts
    91

    move record {Resolved}

    hi, is it possible to move a record from one db to antoher???

    i'm using ADO and SQL

    thanx in advance


    splazz
    Last edited by splazz; Nov 5th, 2002 at 08:11 AM.

  2. #2
    Fanatic Member Gaffer's Avatar
    Join Date
    Nov 2000
    Location
    London
    Posts
    828
    Move:

    cn.Execute "insert into newTable select * from oldTable"
    cn.Execute "delete from oldTable"

    Copy:

    cn.Execute "insert into newTable select * from oldTable"

  3. #3

    Thread Starter
    Lively Member splazz's Avatar
    Join Date
    Sep 2002
    Posts
    91
    thanx, but i've never heard of cn.Execute...

    what about:

    mySQL = "INSERT INTO historie SELECT * FROM bestilling WHERE id=" & bestid


    splazz

  4. #4
    Fanatic Member Gaffer's Avatar
    Join Date
    Nov 2000
    Location
    London
    Posts
    828
    Originally posted by splazz
    thanx, but i've never heard of cn.Execute...

    what about:

    mySQL = "INSERT INTO historie SELECT * FROM bestilling WHERE id=" & bestid


    splazz
    All that is doing is allocating a SQL string to a variable mySQL. You still need to execute it...

  5. #5
    Hyperactive Member
    Join Date
    Oct 2001
    Location
    Washington, DC
    Posts
    422
    mySQL = "INSERT INTO historie SELECT * FROM bestilling WHERE id=" & bestid

    YourConnection.Execute mySQL

  6. #6

    Thread Starter
    Lively Member splazz's Avatar
    Join Date
    Sep 2002
    Posts
    91
    i don't understand much of it, but is this right?:

    Set con = New ADODB.Connection
    Set rs = New ADODB.Recordset

    mystring = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=GMDB.mdb;Persist Security Info=False"
    mySQL = "INSERT INTO historie SELECT * FROM bestilling WHERE id=" & bestid

    con.Open (mystring)
    rs.Open mySQL, con, adOpenKeyset, adLockOptimistic

    con.Execute (mySQL)

    rs.close
    con.close


    splazz

  7. #7
    Fanatic Member
    Join Date
    Apr 2002
    Posts
    638
    yes, but you don't need to open a recordset to execute it. just use this:

    VB Code:
    1. Set con = New ADODB.Connection
    2.  
    3. mystring = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=GMDB.mdb;Persist Security Info=False"
    4. mySQL = "INSERT INTO historie SELECT * FROM bestilling WHERE id=" & bestid
    5.  
    6. con.Open (mystring)
    7. con.Execute (mySQL)
    8.  
    9. con.close

  8. #8

    Thread Starter
    Lively Member splazz's Avatar
    Join Date
    Sep 2002
    Posts
    91
    it won't work, i don't get any error-messages when i run it, but i don't moves anything...


    splazz

  9. #9
    Frenzied Member swatty's Avatar
    Join Date
    Aug 2002
    Location
    somewhere on earth
    Posts
    1,478
    If you don't suply column names and values you have to be sure all columns are identical in table historie and table bestilling and that they are of the same name , type and in the same order .
    Code:
    If Question = Incomplete Then
       AnswerNextOne
    Else
       ReplyIfKnown
    End If
    cu Swatty

  10. #10
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170
    Are your ADO references set?

  11. #11

    Thread Starter
    Lively Member splazz's Avatar
    Join Date
    Sep 2002
    Posts
    91
    thanx a lot guys, it works!!

    it was just the column-problem...


    splazz

Posting Permissions

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



Click Here to Expand Forum to Full Width