Emma123
01-02-2009, 03:49 PM
Hi I have a database with photos and text. I can copy the text from one DB to another without any problems but I'm having trouble copying the photos. Someone suggested using an INSERT Statement. I'm not sure how it works but this is what I have so far. Can anyone help me I'm really stuck.
'Read in the record number to be inserted
RecordNo3 = CLng(Request.QueryString("ID"))
'Create an ADO connection object
Set Conn3 = Server.CreateObject("ADODB.Connection")
'Set an active connection to the Connection object using a DSN-less connection
Conn3.Open "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & Server.MapPath("\db\FileDB.mdb")
'Create an ADO recordset object
Set oRS3 = Server.CreateObject("ADODB.Recordset")
'Initialise the strSQL variable with an SQL statement to query the database
sSQL3 = "SELECT Files.* FROM Files WHERE ID=" & RecordNo3
Set oRS3 = Conn3.Execute(sSQL3)
'Reset server objects
Set Conn3 = Nothing
'Create an ADO connection object
Set Conn4 = Server.CreateObject("ADODB.Connection")
Conn4.Open "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & Server.MapPath("\db\FileDB_bak.mdb")
'Create an ADO recordset object
Set oRS4 = Server.CreateObject("ADODB.Recordset")
sSQL4 = INSERT INTO Files VALUES oRS3
Set oRS4 = Conn4.Execute(sSQL4)
'Reset server objects
oRS4.Close
Set oRS4 = Nothing
Set Conn4 = Nothing
This is the line I'm having problems with sSQL4 = INSERT INTO Files VALUES oRS3 not sure how to put two SQL statement together? Thanks
'Read in the record number to be inserted
RecordNo3 = CLng(Request.QueryString("ID"))
'Create an ADO connection object
Set Conn3 = Server.CreateObject("ADODB.Connection")
'Set an active connection to the Connection object using a DSN-less connection
Conn3.Open "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & Server.MapPath("\db\FileDB.mdb")
'Create an ADO recordset object
Set oRS3 = Server.CreateObject("ADODB.Recordset")
'Initialise the strSQL variable with an SQL statement to query the database
sSQL3 = "SELECT Files.* FROM Files WHERE ID=" & RecordNo3
Set oRS3 = Conn3.Execute(sSQL3)
'Reset server objects
Set Conn3 = Nothing
'Create an ADO connection object
Set Conn4 = Server.CreateObject("ADODB.Connection")
Conn4.Open "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & Server.MapPath("\db\FileDB_bak.mdb")
'Create an ADO recordset object
Set oRS4 = Server.CreateObject("ADODB.Recordset")
sSQL4 = INSERT INTO Files VALUES oRS3
Set oRS4 = Conn4.Execute(sSQL4)
'Reset server objects
oRS4.Close
Set oRS4 = Nothing
Set Conn4 = Nothing
This is the line I'm having problems with sSQL4 = INSERT INTO Files VALUES oRS3 not sure how to put two SQL statement together? Thanks