RE: MyOdbc to unix
Hi ! > -Original Message- > From: SRIVATSAN RAGHURAMAN [mailto:[EMAIL PROTECTED]] > Sent: Tuesday, August 07, 2001 6:13 PM > To: [EMAIL PROTECTED] > Subject: RE: MyOdbc to unix > > > Hi Sinisa, > Sorry I should have mentioned this earlier. From Windows. > R.Srivatsan > [EMAIL PROTECTED] > ___ > Sinisa Milivojevic <[EMAIL PROTECTED]> Wrote--- > SRIVATSAN RAGHURAMAN writes: > > Hi Venu, > > I want some sample codes for ODBC connection to MySQL. > Where can I get it? > > R.Srivatsan > > [EMAIL PROTECTED] > > > To connect from Unix or from Windows ?? We are sorry to say this, at present there is no MyODBC samples available for the public. We are in the plan of distributing some basic samples with the next release version of the driver, shortly. FYI, to establish a connection to MySQL through MyODBC, follow the following instrcutions: -- Download MyODBC driver from http://www.mysql.com/downloads/api-myodbc.html -- Follow the instructions from the online manual to install and configure the DSN. http://www.mysql.com/documentation/mysql/bychapter/manual_ODBC.html#ODBC -- If you want to use it on Unix, configure the MyODBC with iODBC or unixODBC. Please read the following archive which gives complete details in setting up the MyODBC with iODBC/unixODBC: http://lists.mysql.com/cgi-ez/ezmlm-cgi?5:mss:3657:200108:einnhiokafobjmjbmc bm -- Once DSN (lets say MyTest) as configured in ODBC.INI, write a simple C-ODBC as given below and build it by linking through DM libraries. On NT, use odbc32.lib. Hope this helps you, let me know if you have any questions on this. Regards Venu /* Common system headers */ #include /* for WINDOWS */ #include #include /* MS SQL API headers */ #include #include /* PROTOTYPE */ void tmysql_error(RETCODE rc,HENV henv,HDBC hdbc,HSTMT hstmt); void my_test(HDBC hdbc,HSTMT hstmt); /* UTILITY MACROS */ #define MyEnvCHECK(henv,r) \ if ( ((r) != SQL_SUCCESS) ) \ tmysql_error(r, henv, NULL, NULL); \ assert( ((r) == SQL_SUCCESS) || ((r) == SQL_SUCCESS_WITH_INFO) ) #define MyConCHECK(hdbc,r) \ if ( ((r) != SQL_SUCCESS) ) \ tmysql_error(r, NULL, hdbc, NULL); \ assert( ((r) == SQL_SUCCESS) || ((r) == SQL_SUCCESS_WITH_INFO) ) #define MyStmtCHECK(hstmt,r) \ if ( ((r) != SQL_SUCCESS) ) \ tmysql_error(r, NULL, NULL, hstmt); \ assert( ((r) == SQL_SUCCESS) || ((r) == SQL_SUCCESS_WITH_INFO) ) void main() { HENV henv; HDBC hdbc; HSTMT hstmt; RETCODE rc; char *dsn= "MyTest"; char *uid= "username"; char *pwd= "password"; /* ALLOCATE ENVIRONMENT HANDLE */ rc = SQLAllocEnv(&henv); MyEnvCHECK(henv,rc); /* ALLOCATE CONNECTION HANDLE */ rc = SQLAllocConnect(henv, &hdbc); MyEnvCHECK(henv,rc); /* CONNECT TO THE SERVER */ printf("connecting to '%s' with user name '%s'...\n",dsn,uid); rc = SQLConnect(hdbc, dsn, SQL_NTS, uid, SQL_NTS, pwd, SQL_NTS); MyConCHECK(hdbc,rc); /* ALLOCATE STATEMENT HANDLE */ rc = SQLAllocStmt(hdbc, &hstmt); MyConCHECK(hdbc,rc); /* CALL FUNCTION TO PERFORM BASIC SQL OPS */ my_test(hdbc, hstmt); /* FREE ALL HANDLES and DISCONNECT FROM SERVER */ rc = SQLFreeStmt(hstmt, SQL_DROP); MyStmtCHECK(hstmt,rc); printf("disconnecting from server ...\n"); rc = SQLDisconnect(hdbc); MyConCHECK(hdbc,rc); rc = SQLFreeConnect(hdbc); MyConCHECK(hdbc,rc); rc = SQLFreeEnv(henv); MyEnvCHECK(henv,rc); } /* END OF MAIN */ /** Simple function to do basic ops with MySQL */ void myodbc_test(HDBC hdbc,HSTMT hstmt) { RETCODE rc; int nInData = 1; int nOutData, nRowCount; char szOutData[31]={0}; /* CREATE TABLE 'myodbc' */ SQLExecDirect(hstmt,"drop table tmyodbc ",SQL_NTS); rc = SQLExecDirect(hstmt,"create table tmyodbc (col1 int, col2 varchar(30))",SQL_NTS); MyStmtCHECK(hstmt,rc); rc = SQLTransact(NULL,hdbc,SQL_COMMIT); MyConCHECK(hdbc,rc); rc = SQLFreeStmt(hstmt,SQL_CLOSE); MyStmtCHECK(hstmt,rc); /* DIRECT INSERT */ rc = SQLExecDirect(hstmt,"insert into tmyodbc values(10,'direct-insert')",SQL_NTS); MyStmtCHECK(hstmt,rc); /* PREPARE INSERT */ rc = SQLPrepare(hstmt,"insert into tmyodbc values(?,'PARAM_INSERT')",SQL_NTS); MyStmtCHECK(hstmt,rc); rc = SQLBindParameter(hstmt,1,SQL_PARAM_INPUT, SQL_C_LONG,SQL_INTEGER, 0,0,&nIndata,0,NULL); MyStmtCHECK(hstmt,rc); for (nIndata=20 ; nIndata<100; nIndata=index+10) { rc = SQLExecute(hstmt);
RE: MyOdbc to unix
Hi Sinisa, Sorry I should have mentioned this earlier. From Windows. R.Srivatsan [EMAIL PROTECTED] ___ Sinisa Milivojevic <[EMAIL PROTECTED]> Wrote--- SRIVATSAN RAGHURAMAN writes: > Hi Venu, > I want some sample codes for ODBC connection to MySQL. Where can I get it? > R.Srivatsan > [EMAIL PROTECTED] To connect from Unix or from Windows ?? -- Regards, __ ___ ___ __ / |/ /_ __/ __/ __ \/ /Mr. Sinisa Milivojevic <[EMAIL PROTECTED]> / /|_/ / // /\ \/ /_/ / /__ MySQL AB, FullTime Developer /_/ /_/\_, /___/\___\_\___/ Larnaca, Cyprus <___/ www.mysql.com - Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
RE: MyOdbc to unix
SRIVATSAN RAGHURAMAN writes: > Hi Venu, > I want some sample codes for ODBC connection to MySQL. Where can I get it? > R.Srivatsan > [EMAIL PROTECTED] To connect from Unix or from Windows ?? -- Regards, __ ___ ___ __ / |/ /_ __/ __/ __ \/ /Mr. Sinisa Milivojevic <[EMAIL PROTECTED]> / /|_/ / // /\ \/ /_/ / /__ MySQL AB, FullTime Developer /_/ /_/\_, /___/\___\_\___/ Larnaca, Cyprus <___/ www.mysql.com - Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
RE: MyOdbc to unix
Hi Venu, I want some sample codes for ODBC connection to MySQL. Where can I get it? R.Srivatsan [EMAIL PROTECTED] - Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
RE: MyOdbc to unix
Hi ! > -Original Message- > From: Glyndower [mailto:[EMAIL PROTECTED]] > Sent: Tuesday, July 31, 2001 9:49 AM > To: [EMAIL PROTECTED] > Subject: RE: MyOdbc to unix > > > Re my previous message about tech support and access from windoze to unix. > follows is the response i recieved from them: > > "Can you provide the command line sequence sent to the servers in terms > of user, pass, db name, hostname, etc? remember that the hostname is > localhost for mysql. From there we should be able to figure the rest." > > Can somebody help me answer this? I know the user pass dbname etc, but i'm > unsure as to the format that MyOdbc uses to send it along, is it telnet, > php, cgi? > If am not wrong, you want to know the connection string that MyODBC uses to connect to MySQL server running on local host ? Generally for ODBC, here is the format of the connection string: "DSN=data_source_name;UID=username;PWD=password" where in DSN <-- Data Source Name UID <-- User Name PWD <-- Password On Unix, when you want to use MyODBC without any driver managers, then you need to link the MyODBC static library to your application, which will use only MyODBC at run time. On the other hand, when you are loading the MyODBC at run time through iODBC/unixODBC driver managers, you need to create the DSN for MyODBC by adding some fixed definitions to ODBC.INI and ODBCINST.INI (optional), which normally resides in /usr/etc directory, which inclides -- DSN name (user choise) -- Path and the file name of the MyODBC driver -- Listening protocal and port -- Server name -- Database name -- UserName and Password -- General Description (optional) and so on. So, when the ODBC application is linked with iODBC/unixODBC, at run time the Driver Manager(iODBC/unixODBC) validates the DSN given in the SQLConnect/SQLDriverConnect APIs and based on that it loads a particular driver by reading the driver/DSN related options from ODBC.INI Once this DSN validation (Loading the respective driver) is done means, MyODBC driver sends the following information to the server for the connection purpose by reading it from ODBC.INI: -- Host Name -- User Name -- Password -- DSN -- Database Name -- Listening port For more details about ODBC connection and its parameters, please refer to the following MyODBC online manual from MySQL AB. http://www.mysql.com/documentation/mysql/bychapter/manual_ODBC.html#ODBC If you need any further assistance, please send the comments to [EMAIL PROTECTED], that way it will be exposed to MyODBC community. Thanks in advance venu - Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
RE: MyOdbc to unix
Hi ! > -Original Message- > From: Glyndower [mailto:[EMAIL PROTECTED]] > Sent: Tuesday, July 31, 2001 9:49 AM > To: [EMAIL PROTECTED] > Subject: RE: MyOdbc to unix > > > Re my previous message about tech support and access from windoze to unix. > follows is the response i recieved from them: > > "Can you provide the command line sequence sent to the servers in terms > of user, pass, db name, hostname, etc? remember that the hostname is > localhost for mysql. From there we should be able to figure the rest." > > Can somebody help me answer this? I know the user pass dbname etc, but i'm > unsure as to the format that MyOdbc uses to send it along, is it telnet, > php, cgi? > If am not wrong, you want to know the connection string that MyODBC uses to connect to MySQL server running on local host ? Generally for ODBC, here is the format of the connection string: "DSN=data_source_name;UID=username;PWD=password" where in DSN <-- Data Source Name UID <-- User Name PWD <-- Password On Unix, when you want to use MyODBC without any driver managers, then you need to link the MyODBC static library to your application, which will use only MyODBC at run time. On the other hand, when you are loading the MyODBC at run time through iODBC/unixODBC driver managers, you need to create the DSN for MyODBC by adding some fixed definitions to ODBC.INI and ODBCINST.INI (optional), which normally resides in /usr/etc directory, which inclides -- DSN name (user choise) -- Path and the file name of the MyODBC driver -- Listening protocal and port -- Server name -- Database name -- UserName and Password -- General Description (optional) and so on. So, when the ODBC application is linked with iODBC/unixODBC, at run time the Driver Manager(iODBC/unixODBC) validates the DSN given in the SQLConnect/SQLDriverConnect APIs and based on that it loads a particular driver by reading the driver/DSN related options from ODBC.INI Once this DSN validation (Loading the respective driver) is done means, MyODBC driver sends the following information to the server for the connection purpose by reading it from ODBC.INI: -- Host Name -- User Name -- Password -- DSN -- Database Name -- Listening port For more details about ODBC connection and its parameters, please refer to the following MyODBC online manual from MySQL AB. http://www.mysql.com/documentation/mysql/bychapter/manual_ODBC.html#ODBC If you need any further assistance, please send the comments to [EMAIL PROTECTED], that way it will be exposed to MyODBC community. Thanks in advance venu - Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
RE: MyOdbc to unix
Re my previous message about tech support and access from windoze to unix. follows is the response i recieved from them: "Can you provide the command line sequence sent to the servers in terms of user, pass, db name, hostname, etc? remember that the hostname is localhost for mysql. From there we should be able to figure the rest." Can somebody help me answer this? I know the user pass dbname etc, but i'm unsure as to the format that MyOdbc uses to send it along, is it telnet, php, cgi? database - Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
RE: MyOdbc to unix
Hi ! > -Original Message- > From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]] > Sent: Friday, July 27, 2001 11:54 AM > To: [EMAIL PROTECTED] > Subject: MyOdbc to unix > > > Ok, I can't seem to find the answer to this which leads to believe its obvious, but anyway. MyOdbc can be used to connect an Access database on > a Windoze machine to a MySql server on a unix machine, correct? The reason I;m asking is that tech support went , huh? So now I'm questioning my > sanity. Yes. You can. :-Venu - Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php