[PHP] Access db zonder dsn benaderen.

Pagina: 1
Acties:

  • thijsc
  • Registratie: Augustus 2000
  • Laatst online: 22-12-2023
Ik weet dat de vraag waarschijnlijk al eerder gesteld is, maar ik kon het antwoord niet vinden in de search.

Hoe kan ik met php een access db benaderen met een connection string?

Ik kan dus geen systeem dsn aanmaken.

Ik heb deze geprobeerd:
PHP:
1
2
3
4
5
6
7
<?
odbc_connect("DBQ=d:\****\guestbook.mdb;DRIVER={Microsoft Access Driver (*.mdb)}","","");



odbc_connect("DBQ=d:\****\guestbook.mdb","","");
?>

  • thijsc
  • Registratie: Augustus 2000
  • Laatst online: 22-12-2023
Ok, ik heb even doorgezocht, mocht iemand interesse hebben:

op php.weblogs.com/ADODB is dit te vinden.

  • tomato
  • Registratie: November 1999
  • Niet online
[topic=106522]

[topic=120275]

[topic=129323]

  • thijsc
  • Registratie: Augustus 2000
  • Laatst online: 22-12-2023
Op maandag 19 maart 2001 22:49 schreef tomato het volgende:
[topic=106522]

[topic=120275]

[topic=129323]
Dank je voor deze links.

Hier is dus totaal niets te vinden over het onderwerp (php met access zonder DSN).

  • tomato
  • Registratie: November 1999
  • Niet online
Oeps iets te snel gelezen :o. Was beetje duf blijkbaar, sorry.

Verwijderd

Op http://php.weblogs.com/odbc staat het antwoord dat je zoekt:
Creating DSN-less connections
DSN's have to be created from the Control Panel. Sometimes, you don't have access to the Control Panel on the webserver. You need to use a DSN-less connection instead.


Now the bad news is that DSN-less connections don't seem to work with PHP's ODBC extension. DSN-less connections do work with Microsoft's ADO, which is Microsoft's COM based API which is higher level and supposedly easier to use than native ODBC. ADO Example.

I have ported the ADODB class library to support ADO, and it now available at the above link. This class library supports DSN-less connections.

An example using ADODB, adapted from testdatabases.inc.php:
PHP:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
<?
php



include('adodb.inc.php'); 



ADOLoadCode("ado_mssql");



$db = &amp;ADONewConnection("ado_mssql");



print "<h1>Connecting DSN-less $db->databaseType...</h1>";



    



$myDSN="PROVIDER=MSDASQL;DRIVER={SQL Server};"



    . "SERVER=flipper;DATABASE=ai;UID=sa;PWD=;"  ;



$db->Connect($myDSN);







$rs = $db->Execute("select * from table");



$arr = $rs->GetArray();



print_r($arr);
?>
En dat was 1 HREFje van de link die jij opgaf.

Enjoy :)

  • Guillome
  • Registratie: Januari 2001
  • Niet online

Guillome

test

En hoe werkt dat dan precies?

Stel: Ik heb een database db.mdb. Die staat in de dir //computer/database
Hoe maak ik dan die koppeling?

If then else matters! - I5 12600KF, Asus Tuf GT501, Gigabyte Gaming OC 16G 5080 RTX, Asus Tuf Gaming H670 Pro, 48GB, Corsair RM850X PSU, SN850 1TB, Arctic Liquid Freezer 280, ASUS RT-AX1800U router


  • Pelle
  • Registratie: Januari 2001
  • Laatst online: 09-09 23:47

Pelle

🚴‍♂️

Op dinsdag 16 april 2002 10:53 schreef XLerator het volgende:
En hoe werkt dat dan precies?
Dat staat hierboven toch gewoon beschreven :?
Erg oud topic overigens..

  • Guillome
  • Registratie: Januari 2001
  • Niet online

Guillome

test

Wat maakt het nou uit of het een oude topic is.
Ik kon ook wel een nieuwe starten, maar dit is logischer.
Maar wat daar boven staat, dat werkt namelijk niet.
Daar moet je nog vanalles invullen, alleen, na 1.5 uur klungelen kom ik er niet uit.

If then else matters! - I5 12600KF, Asus Tuf GT501, Gigabyte Gaming OC 16G 5080 RTX, Asus Tuf Gaming H670 Pro, 48GB, Corsair RM850X PSU, SN850 1TB, Arctic Liquid Freezer 280, ASUS RT-AX1800U router

Pagina: 1