Avatar billede fredand Forsker
18. oktober 2002 - 10:05 Der er 14 kommentarer og
1 løsning

Connect to a database with ASP?

Hello!

I have found out that the best way to connect to a database should be this way:

Set myDatabaseConnection = Server.CreateObject("ADODB.Connection")
databasePath = "../database/school.mdb"
connectionString = "PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA SOURCE="
connectionString = connectionString & server.mappath(databasePath) & ";"
myDatabaseConnection.open connectionString

But now is my question how should I connect to a database like MySQL like this?

Access builds one file of the database.

MySQL builds 3 files if I am not wrong, and I guess that MySQL must be running as well?

So is it possible to connect to a MySQL, MS SQL Server or other bigger database like the example above?

Best regards

Fredrik
Avatar billede keysersoze Ekspert
18. oktober 2002 - 10:10 #1
både og - et eksempel på mysql;

Set Conn = Server.CreateObject("ADODB.Connection")
Conn.Open "DRIVER={mysql};SERVER=database_server;DATABASE=database;UID=brugernavn;PWD=password;"

og så mssql;

set conn = server.createobject("adodb.connection")
conn.open "PROVIDER=MSDASQL;DRIVER={SQL Server};SERVER=database_server;uid=brugernavn;pwd=password;DATABASE=database"
Avatar billede fredand Forsker
18. oktober 2002 - 10:28 #2
Hello!

But I guess I can't just copy the files in MySql togheter with the ASP-app to an other computer and run? I need the MySql-application as well?

With other words: Is it only possible to move an application in ASP to an other system with a database like Access that builds one databasefile that can be used with out the database application?

Best regards

Fredrik
Avatar billede keysersoze Ekspert
18. oktober 2002 - 16:42 #3
do you understand danish or do you prefer english?
Avatar billede fredand Forsker
21. oktober 2002 - 08:15 #4
Hello!

I'm from sweden and I have some difficulties to understand danish I'm afraid. So prefer english if this it is OK.

Best regards
Fredrik
Avatar billede keysersoze Ekspert
21. oktober 2002 - 10:56 #5
ok...

access/asp can be moved to everywhere where you have an ASP-server - that means a computer with PWS/ISS

MySQL/asp is not so easy to move, but first of all you need a PWS/IIS server again so that the ASP can be runned. MySQL needs a MySQL-"server" (that just mysql in itself) and the MYODBC driver - if that is installed on the other computer it is easy to move the database alså, but it needs one change in the setup (in the db-connection in your ASP) because the servername, username and password can be a different from the original computer.

but does the other computer not support MySQL it is not possible to move the asp/mysql files and then expect the site to run...

hope that answers your question - else just ask
Avatar billede fredand Forsker
21. oktober 2002 - 11:33 #6
Hello!

Then I guess that is not possible at all to connect to a MySQL or MSSQL with PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA since it seems to use a path to a database file?

/Fredrik
Avatar billede keysersoze Ekspert
21. oktober 2002 - 11:37 #7
correct - each database have its own connection... thats why i said you have to write this to connect to mysql;

Conn.Open "DRIVER={mysql};SERVER=database_server;DATABASE=database;UID=brugernavn;PWD=password;"


and mssql

set conn = server.createobject("adodb.connection")
conn.open "PROVIDER=MSDASQL;DRIVER={SQL Server};SERVER=database_server;uid=brugernavn;pwd=password;DATABASE=database"
Avatar billede fredand Forsker
21. oktober 2002 - 11:48 #8
Hmm!
Ok, just one more question.

For MySQL you use:
Conn.Open "DRIVER={mysql};SERV.....

But for MSSQL you use:
conn.open "PROVIDER=MSDASQL;DRIVER={SQL Server};SERV...

What does "PROVIDER=MSDASQL; do for good since you do not use it with MySQL?

Best regards
Fredrik
Avatar billede keysersoze Ekspert
21. oktober 2002 - 11:58 #9
well - it is to different drivers... you cant install your graficcard sith the drivers from your soundcard
Avatar billede fredand Forsker
21. oktober 2002 - 14:00 #10
Hmm!

But it seems to be total different technics:

For MySQL you use:
Conn.Open "DRIVER={mysql};SERV.....

But for MSSQL you use:
conn.open "PROVIDER=MSDASQL;DRIVER

For MYSQL you do not use Provider at all, but a driver. Can you explaine what the Provider does, compare to just use the driver.

Best regards
Fredrik
Avatar billede keysersoze Ekspert
21. oktober 2002 - 14:56 #11
they just have each their way - with access you can also connect with a driver instead of a provider
Avatar billede fredand Forsker
21. oktober 2002 - 15:00 #12
Then my absolute last question, it is not possible to connect to a MySql with the PROVIDER-way?

Best regards
Fredrik
Avatar billede keysersoze Ekspert
21. oktober 2002 - 15:10 #13
dunno - maybe you can read it at www.mysql.com

but is it important to do that?
Avatar billede fredand Forsker
22. oktober 2002 - 08:54 #14
I just would like to know all the ways it is possible to connect to a database and wich one is the best.

Best regrads and tanks for your time.
Fredrik Andersson
Avatar billede keysersoze Ekspert
22. oktober 2002 - 10:04 #15
The "provider"-method connects directly to JET which is the database - but the "driver"-method connects to access which is only a frontend to the database JET. Therefore the way to tha data is shorter with the "provider"-method...

but i cannot answer that talking about mysql and mssql - but as far as i know there is only one way to these databases... but again; on the mysql and microsoft pages it should be possible to read much more
Avatar billede Ny bruger Nybegynder

Din løsning...

Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.

Loading billede Opret Preview
Kategori
Kurser inden for grundlæggende programmering

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester