Current location: Hot Scripts Forums » Programming Languages » ASP » asp sql table copy bet. 2 databases access


asp sql table copy bet. 2 databases access

Reply
  #1 (permalink)  
Old 04-10-11, 09:17 AM
realmeteo realmeteo is offline
New Member
 
Join Date: Apr 2011
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
asp sql table copy bet. 2 databases access

I have two databases access on my asp server.

First is on ----------------- first = Server.MapPath("/public/sourcedb.mdb")
Second is on is on ---------- second = Server.MapPath("/public/destinationdb.mdb")

I like to copy table "Users" from First to Second with asp sql code same at "SELECT * INTO second.Users FROM first.Users" but cant write correct sintax

Help me please

include code used

Code:
file config.asp
<%
    Option Explicit
    On Error Resume Next
    Response.Buffer = True
    Response.Expires = 0
    ' ----- ----- ----- ----- -----
    Dim sc, cn, rs, cn_bk, rs_bk
    ' ----- ----- ----- ----- -----
    Function ConnOpen()
        sc = "driver={Microsoft Access Driver (*.mdb)};dbq="
        sc = sc & Server.MapPath("/mdb-database/ecom.mdb")
        Set cn = Server.CreateObject("ADODB.Connection")
        Set rs = Server.CreateObject("ADODB.Recordset")
        cn.Open sc
    End Function
    ' ----- ----- ----- ----- -----
    Function ConnClose()
        Set rs = Nothing
        cn.Close
        Set cn = Nothing
    End Function
    ' ----- ----- ----- ----- -----
    Function BackupOpen()
        sc = "driver={Microsoft Access Driver (*.mdb)};dbq="
        sc = sc & Server.MapPath("/mdb-database/master.mdb")
        Set cn_bk = Server.CreateObject("ADODB.Connection")
        Set rs_bk = Server.CreateObject("ADODB.Recordset")
        cn_bk.Open sc
    End Function
    ' ----- ----- ----- ----- -----
    Function BackupClose()
        Set rs_bk = Nothing
        cn_bk.Close
        Set cn_bk = Nothing
    End Function
%>



file copitable.asp
<%@LANGUAGE = VBScript%>
<!--#include file="config.asp"-->
<%
    If Session("ADMIN") <> "OK" Then
        Response.Redirect "default.asp"
    End If
    Dim backup
    backup = Request.QueryString("backup")
%>
<html>
<head>
<title>Dump e backup di un database con ASP</title>
</head>
<body>

<h1>Effettua il dump del database</h1>

<form method="post" action="dump.asp?backup=OK">
    <input type="submit" value="DUMP">
</form>

<a href="logout.asp">Logout</a><br><br>

<%
    If backup = "OK" Then
    	


	  Dim SQL
      Call ConnOpen()
          Call BackupOpen()
           		SQL= " INSERT INTO  prodotti  (Codice, SCategoria, Categoria, Prodotto, 	PDescrizione) SELECT  FROM "& Server.MapPath("/mdb-database/master.mdb").prodotti  (Codice, SCategoria, Categoria, Prodotto, 	PDescrizione)
           		Set RS = cn.Execute(SQL)
           		RS.Close
           
           Call BackupClose()
      Call ConnClose()


    End If
%>

</body>
</html>
it not work!
cable is not copied
help me please
Reply With Quote
  #2 (permalink)  
Old 04-11-11, 12:17 AM
job0107's Avatar
job0107 job0107 is offline
Community Liaison
 
Join Date: Dec 2006
Location: Tacoma, Washington USA
Posts: 3,454
Thanks: 0
Thanked 140 Times in 137 Posts
Try using the The SQL SELECT INTO Statement.
SQL SELECT INTO Statement
__________________
Jerry Broughton
Reply With Quote
  #3 (permalink)  
Old 04-11-11, 01:31 AM
realmeteo realmeteo is offline
New Member
 
Join Date: Apr 2011
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Thank you,
my problem is that I don't know how the correct sintax for use this command in my asp scrpt.

I done some test but all fails:

Code:
Dim SQL
      Call ConnOpen()
          Call BackupOpen()
           		_???_ SQL= " INSERT INTO  prodotti  (Codice, SCategoria, Categoria, Prodotto, PDescrizione) SELECT  (Codice, SCategoria, Categoria, Prodotto, PDescrizione) FROM "& Server.MapPath("/mdb-database/master.mdb").prodotti 
           		_???_ Set RS = cn.Execute(SQL)
           		RS.Close           
           Call BackupClose()
      Call ConnClose()
my problem is how to run this command in asp (look for _???_)
can you help me?
Reply With Quote
  #4 (permalink)  
Old 04-12-11, 12:44 AM
job0107's Avatar
job0107 job0107 is offline
Community Liaison
 
Join Date: Dec 2006
Location: Tacoma, Washington USA
Posts: 3,454
Thanks: 0
Thanked 140 Times in 137 Posts
No, I don't know enough about ASP to help you.
But I did notice that you are trying to copy the contents of one table to another table in a different database on the same server.
You are trying to use the INSERT INTO command, but after some investigation I believe you should be using the SELECT INTO command to perform your task.
From what I can understand, it looks like it is fairly easy to setup.
__________________
Jerry Broughton
Reply With Quote
Reply

Bookmarks

Tags
access, asp, asql, databases


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
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

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Upload .xls file from client's machine to SQL Server table bubberz ASP.NET 0 08-09-05 02:40 PM
How to do multiple SQL queries in asp? minority ASP 3 06-23-05 03:07 AM
sorting table using asp with vbscript. wsy_bin ASP 4 05-05-05 02:54 AM
php - copy ACCESS db. feffik PHP 0 04-04-05 09:23 AM


All times are GMT -5. The time now is 04:11 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.