Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Insert data from 1 .mdb to another .mdb thru asp? 1

Status
Not open for further replies.

Samoyed

Programmer
Jul 13, 2001
17
CA
Hi,

From an asp page I am trying to copy data from one table in my PAC.mdb into another database called TestCopyTo.mdb. They both sit elsewhere on the server. I tried using the code below but I get an error (shown at bottom)
<%
Dim SQLstatement As String = "Insert Into 9809 Select * From SinglePAC IN " _
C:\database\PAC.mdb"

Dim myOleDBConnection As OleDbConnection = New
OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\database\TestCopyTo.mdb")

Dim myOleDBCommand As New OleDbCommand(SQLstatement, myOleDBConnection)

myOleDBCommand.Connection.Open()
myOleDBCommand.ExecuteNonQuery()
myOleDBCommand.Connection.Close
%>

Error Type:
Microsoft VBScript compilation (0x800A0401)
Expected end of statement
/PAC/CreatePACtemp.asp, line 29, column 17
Dim SQLstatement As String = "Insert Into 9809 Select * From SinglePAC IN " _
----------------^

Has anyone done anything like this before? If so can you pls share your insight?

Thx
 
are you trying to write ASP+ or classic ASP?
I'm thinking not ASP+ as that looks a whole lot like VB6

reasoning is that is not vbscript and Classic ASP does not take VB very well



___________________________________________________________________
[sub]
The answer to your ??'s may be closer then you think.
Check out Tek-Tips knowledge bank by clicking the FAQ link at the top of the page
[/sub]
 
The error your getting is because you don't have you string concatenated correctly, your missing an ampersand and a quote:
Code:
 Dim SQLstatement As String = "Insert Into 9809 Select * From SinglePAC IN " & _
    "C:\database\PAC.mdb"

Not so crazy about the SQL statement itself, but that may be just because I have never done a copy that way. Generally I will open a connection to the first database, pull the records back into a recordset, use GetRows to drop that data into an aray, close tyhe recordset and connection, than open the connection to the other database and do batch inserts...

-T

[sub]01000111 01101111 01110100 00100000 01000011 01101111 01100110 01100110 01100101 01100101 00111111[/sub]
The never-completed website:
 
Hi Thx for giving me ideas,

I made my problem much more complex than I really needed to. I changed it to force the user to enter in the parameters instead of just listing in combo boxes what was already present in the mdb. It operates much quicker now after the user inputs.

Thx to all who replied {=-)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top