A tool to convert, through of the page ASP a database from Access to SQL Server.
Made of two pages: With the first one a table is created on SQL Server, with the same fields of the Access database, and with the second you copy the tuples from the access table to the SQL one..
Table creation page
<!--#include file=connessione.inc -->
Connected!<br/>
<%
'In the example I create a table with 3 fields
sql = "CREATE TABLE [table to create] (field1 int, Field2 nvarchar(50), Field3 nvarchar(50))"
conn.Execute sql
%>
Table created <br/>
<%
conn.close
set conn = nothing
%>
Copy values page
<!--#include file=connessione.inc -->
Connected!<br/>
<%
'connection string to access database
path = Request.ServerVariables("APPL_PHYSICAL_PATH")
strconnAccess = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & path & "data\data.mdb"
set connAccess = server.createobject("ADODB.Connection")
connAccess.open strconnAccess
'[Table Name] is the table to copy in SQL Server
sql = "select * from [Table Name]"
set Rs = connAccess.execute(sql)
If rs.eof then
response.write "no element to copy "
response.end
Else
rs.movefirst
Do while not rs.eof
'read values from access and copy to SQL Server
Field1 = rs("Field1")
Field2 = rs("Field2")
Field3 = rs("Field3")
'insert values into sql server
SQL = "insert into AREA_LAVORO (Field1, Field2, Field3) VALUES "
SQL = SQL & "('" & Field1 & "','" & Field2 & "','" & Field3 & "')"
conn.execute(SQL)
rs.MoveNext
loop
End If
%>
Done!<br/>