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

  • Please provide the error text directly in the question. You can correct the issue by clicking edit right below the question text. - aleksandr barakin
  • try to get the number and text of the error. how to do this is difficult to give due to the fact that you did not indicate where and what you use the sqlconnect function. - aleksandr barakin
  • A piece of source code is, of course, useful information, and it should be included in the question (and not in the comment, where there is no formatting), but by β€œwhere and what” I meant, first of all, the programming language and the operating system. - aleksandr barakin

0