Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Empfohlene Antworten

Veröffentlicht

Hallo Leute,

ich versuche mich gerade an einer SQL-Abfrage aus einer ODBC-Datenquelle.

Ausgegeben wird mir aber immer nichts. Kann sich jemand mal den Code ansehen?


$cnx = odbc_connect($dsn,$user,$pwd) or die ("Die Datenbank existiert nicht.");

$cur = odbc_exec($cnx, "SELECT Document No_ FROM XXX$Purchase Line Archive");

while(odbc_fetch_row($cur)) {
$test[]= odbc_result($cur,"Document No_");
}

for($h=0; $h < sizeof($test); $h++) {
echo "Nr: ". $test[$h]."<br>";
}

odbc_close_all();
[/PHP]

Danke schonmal.

  • Autor

Danke für den Hinweis etreu.

Ich habe jetzt mein Code um den Parameter erweitert und bekomme Resource id #1 zurückgeliefert bei der Abfrage:


$cnx = odbc_connect($dsn,$user,$pwd, $cursor_type) or die ("Die Datenbank existiert nicht.");
echo $cnx;
[/PHP]

Soweit ich weiß bedeutet das, dass ein Array in der Variable steht. So soll es auch sein dann scheitert es nur noch irgendwo in der Ausgabe.

Ich habe jetzt mein Code um den Parameter erweitert und bekomme Resource id #1 zurückgeliefert bei der Abfrage:

Du führst keine Abfrage durch, sondern Du baust die Verbindung zu der ODBC Source auf. In Deiner Variablen $cnx steht dann der Handle der Verbindung. Mit Hilfe des Handles kann man dann entsprechende Aktionen durchführen (analog zu den mysql_ Befehlen)

cursor_type

This sets the type of cursor to be used for this connection. This parameter is not normally needed, but can be useful for working around problems with some ODBC drivers.

The following constants are defined for cursortype:

SQL_CUR_USE_IF_NEEDED

SQL_CUR_USE_ODBC

SQL_CUR_USE_DRIVER

SQL_CUR_DEFAULT

  • Autor

Hier mal mein aktueller Code ich vermute mal du meinst SQL_CUR_USE_DRIVER als konstante oder?


<?php
$dsn="Test";
$user="sa";
$pwd="pw";
$cursor_type = SQL_CUR_USE_DRIVER;

$conn = odbc_connect($dsn,$user,$pwd,$cursor_type) or die ("Die Datenbank existiert nicht.");
$sql = 'SELECT No_ FROM Test';
$cur = odbc_exec($conn, $sql);
echo $conn . "<br>";
echo $sql . "<br>";
echo $cur . "<br>";
while(odbc_fetch_row($cur)) {
$test[]= odbc_result($cur,"No_");
}

for($h=0; $h < sizeof($test); $h++) {
echo "Nr: ". $test[$h]."<br>";
}

odbc_close_all();
?>

[/PHP]

  • Autor

ich hab es jetzt hinbekommen mir eine Fehlermeldung anzeigen zu lassen:

Warning: odbc_exec() [function.odbc-exec]: SQL error: [Microsoft][ODBC SQL Server Driver][sql Server]Falsche Syntax in der Nähe von '01'., SQL state 37000 in SQLExecDirect in C:\XXX\Programme\XAMPP\xampp\htdocs\1.php on line 9

@etreu fetch_object hat leider auch nichts gebracht.

Kann jemand was mit der Fehlermeldung anfangen?

Erstelle ein Konto oder melde dich an, um einen Kommentar zu schreiben.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.