There is such a function:
SQLConnect(dbc, driver, SQL_NTS, user, SQL_NTS, pwd, SQL_NTS) driver is the name of the database (as I understand it is stored in the odbc.ini file), user is the login, pwd is the password.
When you try to start the program gives an error.
odbc.ini structure:
[MYDB] Driver = PostgreSQL Trace = Yes TraceFile = sql.log Database = students Servername = fpm2.ami.nstu.ru Password = Port = 5432 Protocol = 9.3 ReadOnly = No RowVersioning = No ShowSystemTablea = No ShowOidColumn = No FakeOidIndex = No ConnSettings = In my case, driver is MYDB .
Piece of code
HENV env; //ΡΠΈΠΏ ΠΈΠ΄Π΅Π½ΡΠΈΡΠΈΠΊΠ°ΡΠΎΡΠ° ΠΎΠΊΡΡΠΆΠ΅Π½ΠΈΡ HDBC dbc; //ΡΠΈΠΏ ΠΈΠ΄Π΅Π½ΡΠΈΡΠΈΠΊΠ°ΡΠΎΡΠ° ΡΠΎΠ΅Π΄Π΅Π½Π΅Π½ΠΈΡ HSTMT stmt, stmt_t, stmt_r; //ΠΈΠ΄Π΅Π½ΡΠΈΡΠΈΠΊΠ°ΡΠΎΡ ΠΎΠΏΠ΅ΡΠ°ΡΠΎΡΠ° int query = 0; if (error(SQLAllocEnv(&env)) < 0) goto end_; if (error(SQLAllocConnect(env, &dbc)) < 0) goto end_; if(error(SQLConnect(dbc, driver, SQL_NTS, user, SQL_NTS, pwd, SQL_NTS))<0) goto end_; Bd - postgresql, program - C using ODBC, operating system - Linux.
Update
Error SQL_ERROR . Those. means that the error is somewhere in the function itself. (error(SQLConnect(dbc, driver, SQL_NTS, user, SQL_NTS, pwd, SQL_NTS))<0) , where error(RETCODE code) error handling.
DB on postgresql, C language using odbc tools, operating system - Linux
sqlconnectfunction. - aleksandr barakin