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.

SQL in C Programm

Empfohlene Antworten

Veröffentlicht

Hy,

was brauch ich alles um mich über ein c programm an nem sql server anzumelden ?

OS ist Cygwin

Compiler gcc

Postgresql ist installiert

Die includes sind "sql.h" und "sqlext.h", richtig ?

Muss ich irgendwas dem compiler als option übergeben ?

Thx

Also, hab mich noch etwas weiter mit Google beschäftigt und weiß jetzt dass man "unixODBC" installiert haben muss. odbcUnix ist in /usr/local installiert.

Hier der Code von nem Beispiel Prog:


#include <stdio.h>

#include <sql.h>

#include <sqlext.h>


main() {

  SQLHENV env;

  char driver[256];

  char attr[256];

  SQLSMALLINT driver_ret;

  SQLSMALLINT attr_ret;

  SQLUSMALLINT direction;

  SQLRETURN ret;


  SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &env);

  SQLSetEnvAttr(env, SQL_ATTR_ODBC_VERSION, (void *) SQL_OV_ODBC3, 0);


  direction = SQL_FETCH_FIRST;

  while(SQL_SUCCEEDED(ret = SQLDrivers(env, direction,

				       driver, sizeof(driver), &driver_ret,

				       attr, sizeof(attr), &attr_ret))) {

    direction = SQL_FETCH_NEXT;

    printf("%s - %s\n", driver, attr);

    if (ret == SQL_SUCCESS_WITH_INFO) printf("\tdata truncation\n");

  }

}

Die Optionen beim Compilen sollten folgende sein: gcc -c odbc.c -I/usr/local/include/ ( laut : http://www.dbmaker.com.tw/reference/manuals/odbc/odbc_chap_02.html ) und dann gcc -o odbc odbc.o -L/usr/local/lib -lodbc laut : http://www.easysoft.com/products/9999/faq_answer.phtml?ID=750&product=2002 ) Nur beim übersetzen kommt jetzt folgendes:

$ gcc -o odbc odbc.o -L/usr/local/lib -lodbc

/usr/local/lib/libodbc.a(__info.o): In function `unicode_shutdown':

/home/test/unixODBC-2.2.11/DriverManager/__info.c:561: undefined reference to `_libiconv_close'

/home/test/unixODBC-2.2.11/DriverManager/__info.c:566: undefined reference to `_libiconv_close'

/usr/local/lib/libodbc.a(__info.o): In function `ansi_to_unicode_copy':

/home/test/unixODBC-2.2.11/DriverManager/__info.c:719: undefined reference to `_libiconv'

/usr/local/lib/libodbc.a(__info.o): In function `unicode_to_ansi_copy':

/home/test/unixODBC-2.2.11/DriverManager/__info.c:664: undefined reference to `_libiconv'

/usr/local/lib/libodbc.a(__info.o): In function `unicode_setup':

/home/test/unixODBC-2.2.11/DriverManager/__info.c:470: undefined reference to `_libiconv_open'

/home/test/unixODBC-2.2.11/DriverManager/__info.c:474: undefined reference to `_libiconv_close'

/home/test/unixODBC-2.2.11/DriverManager/__info.c:534: undefined reference to `_libiconv_open'

/home/test/unixODBC-2.2.11/DriverManager/__info.c:535: undefined reference to `_libiconv_open'

/home/test/unixODBC-2.2.11/DriverManager/__info.c:492: undefined reference to `_libiconv_open'

/home/test/unixODBC-2.2.11/DriverManager/__info.c:495: undefined reference to `_libiconv_close'

collect2: ld returned 1 exit status

Hat jemand ne Ahnung was da nicht stimmt ?

Thx

Hallo!

Ich weis zwar nicht was du da programmiert hast, aber schau dir mal die folgende Seite an:

http://www.pronix.de/pronix-4.html

Unter Punkt 27 ist "MySQL mit C" beschrieben.

Ist zwar für Windows aber man kann sich ein Bild machen was einem noch fehlen kann.

Schau ob du eine Developer - Beschreibung zu deinem Server findest, die APIs für den Zugriff enthält.

Ich hoffe es hilft dir weiter.

Viel Spaß.

Du musst beim Linken noch die ICONV-Bibliothek angeben, also

gcc -o odbc odbc.o -L/usr/local/lib -lodbc -liconv

Archiv

Dieses Thema wurde archiviert und kann nicht mehr beantwortet werden.

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.