Click to See Complete Forum and Search --> : jump from Access to MySQL


Foundas
10-18-2005, 09:06 AM
Hey guys,

i have a database in Access 2000 and i wish to change it to MySQL. Supposly i do the transformation, what is the code to open a MySQL database? Currently, for the access, i have this function to open the database:

Sub OpenDataBase (connection)
database="D:\database\db.mdb"
strconn = "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source='" & database & "';Jet OLEDB:Database Password='passwordforthedatabase';"
Set connection = Server.CreateObject("ADODB.Connection")
connection.open strconn
If connection.errors.count> 1 then
response.write "Error has occured<br>" & connection.errors(0).description
end if
End Sub


and this code to close it:

sub CloseDatabase(connection)
connection.close
set connection=nothing
End sub


Can you please help me out on this? What are the commands to open and close a mysql database?


thanks in advance,

Foundas

JPnyc
10-18-2005, 09:10 AM
"Provider=MySQLProv;Data Source=Your_MySQL_Database;User Id=Your_Username; Password=Your_Password;"

That should be the connection string using ole db.

Robert Wellock
10-18-2005, 10:25 AM
I suppose you already know there are free tools which convert Access *.mdb to MySQL and I assume you just wanted the connection script. It also can depend on the Scripting Language.

Foundas
10-25-2005, 05:40 AM
Following up on this thread,

here is an example (where i add a new entry) on how i currently access the MS Access database using the above mentioned function:

--------------------------------------------------------------------------------
if error="" then
set dbc=nothing
set rs=nothing
OpenDataBase dbc
Set rs1 = Server.CreateObject ("ADODB.Recordset")
rs1.open "users",dbc, 2,3

rs1.addnew
rs1("firstname")=firstname
rs1("lastname")=lastname
rs1.update
rs1.close
set rs1 = nothing

closedatabase dbc
end if
----------------------------------------------------------
This example, is for searching a table in the database:

OpenDataBase conn
mySQL = "SELECT * FROM orders where id=" & orderid & " and completed=False"
Set rs1 = Server.CreateObject("ADODB.Recordset")
rs1.Open mySQL, conn, 2, 3
rs1("completed")=True
rs1("compdate")=mnow
rs1.update
rs1.close
conn.close

--------------------------------------------------------------------

Can you please advice on what i have to change on the above code (function and the way i query the database) in order to start using MySQL instead of MSAccess?

I have already converted the MS database to MySQL

Thanks in advance