odbc

Need a row count after SELECT statement: what's the optimal SQL approach?

两盒软妹~` 提交于 2019-11-27 19:01:16
I'm trying to select a column from a single table (no joins) and I need the count of the number of rows, ideally before I begin retrieving the rows. I have come to two approaches that provide the information I need. Approach 1: SELECT COUNT( my_table.my_col ) AS row_count FROM my_table WHERE my_table.foo = 'bar' Then SELECT my_table.my_col FROM my_table WHERE my_table.foo = 'bar' Or Approach 2 SELECT my_table.my_col, ( SELECT COUNT ( my_table.my_col ) FROM my_table WHERE my_table.foo = 'bar' ) AS row_count FROM my_table WHERE my_table.foo = 'bar' I am doing this because my SQL driver (SQL

Distributed transactions between MySQL and MSSQL

强颜欢笑 提交于 2019-11-27 18:41:23
问题 I've tried for nearly a week now to get distributed transactions working. I've some procedures on MSSQL which try to select data from MySQL. My need is to do this in one(!) transaction. At the time I've set up ODBC connection on MSSQL with Single-Tier MySQL driver from OpenLink, which states me, that XA transactions work successfully (there is a test button integrated after configuring ODBC connection). Then I've set up a linked server in MSSQL via MSDASQL to this ODBC connection, but when

Using Excel as an ODBC database

耗尽温柔 提交于 2019-11-27 18:22:00
问题 I'd like to know, how to create a database table in Excel, so that it may be used with ODBC I want to use ODBC, and I have two options, either MS Access or Excel, As you probably know, in order to indicate some MS Access file or Excel file as an ODBC source, you need to follow: Administrative Tools -> Data Sources (ODBC) -> Choose User DSN -> Choose either 'Excel Files' or 'MS Access Database' from the list -> Press 'Configure' -> finally choose the file (MS Access or Excel) as ODBC source

Can't open lib 'ODBC Driver 13 for SQL Server'? Sym linking issue?

北战南征 提交于 2019-11-27 18:09:43
When I try to connect to a sql server database with pyodbc (on mac): import pyodbc server = '####' database = '####' username = '####@####' password = '#####' driver='{ODBC Driver 13 for SQL Server}' pyodbc.connect('DRIVER='+driver+';SERVER='+server+';PORT=1443;DATABASE='+database+';UID='+username+';PWD='+password) I get the following error: Error: ('01000', "[01000] [unixODBC][Driver Manager]Can't open lib 'ODBC Driver 13 for SQL Server' : file not found (0) (SQLDriverConnect)") When I path in the actual driver location: driver='/usr/local/lib/libmsodbcsql.13.dylib' It starts working! My

Connect PHP to IBM i (AS/400)

我的梦境 提交于 2019-11-27 17:08:44
问题 I've got an upcoming project wherein I will need to connect our website ( PHP5/Apache 1.3/OpenBSD 4.1 ) to our back-end system running on an iSeries with OS400 V5R3 so that I can access some tables stored there. I've done some checking around but am running into some roadblocks. From what I've seen the DB2 extensions and DB2 software from IBM only run under Linux. I've tried compiling the extensions with all the software from IBM and even tried their precompiled ibm_db2 extension with no luck

Microsoft Excel Data Connections - Alter Connection String through VBA

拈花ヽ惹草 提交于 2019-11-27 17:02:37
问题 I have a fairly straightforward question. I am trying to find a way to alter and change a connection string for an existing data connection in an excel workbook through VBA (macro code). The main reason I am trying to do this is to find a way to prompt the user that opens up the workbook to enter their credentials (Username/Password) or have a checkbox for Trusted Connection that would be used in the Connection String of those existing data connections. Right now the Data connections are

Using ODBC to connect to SQL SERVER 2008

空扰寡人 提交于 2019-11-27 16:45:31
问题 I'm on a W32 machine trying to get a connection with a DB. For that purpose, I tried starting testing an example program: #include <iostream> #include <windows.h> #include <sqltypes.h> #include <sql.h> #include <sqlext.h> using namespace std; void show_error(unsigned int handletype, const SQLHANDLE& handle){ SQLCHAR sqlstate[1024]; SQLCHAR message[1024]; if(SQL_SUCCESS == SQLGetDiagRec(handletype, handle, 1, sqlstate, NULL, message, 1024, NULL)) cout<<"Message: "<<message<<"\nSQLSTATE: "<

Python数据库编程入门教程

末鹿安然 提交于 2019-11-27 16:23:26
这年头,还 拿打印"Hello World"做教程?毛主席说了,你这不是耍流氓么!这个时代,数据库是王道!今天,我就用一个简单实用的销售数据库开发案例来引导感兴趣的读者入门Python数据库编程技术。我们将使用Python创建一个简单的Access销售数据库,使用ODBC功能对数据库插入删除销售记录,最后对数据库中的数据进行查询。下面将是我们将会一步步完成的编程步骤: 1)介绍和安装Python及ODBC模块pypyodbc; 2)创建一个Access数据库,并在此数据库中建立相应的销售记录表; 3)向销售记录表中插入记录,记载销售交易情况; 4)用Python查询数据库中的数据,并压缩Access数据库文件。 咱们这就开始! 1)安装Python和pypyodbc模块 Python可以在 www.python.org 中下载。本教程中我们下载的版本是Python 2.7.3,尽管 它 是一个编程平台, 和普通程序一样,选择好安装本地安装路径,一路按“下一步”就可以完成安装。 --有很多人会问,为什么不选择最新的Python 3.X?在今日(2013年1月20日)笔者观点是:如果你想很快就开始用Python开发实际的系统,那么就应该选择Python 2.7。Python 3.X是未来的方向,但由于3.X版本没有很好的向下兼容性,很多可以在Python 2

java.sql.SQLException: No database selected - why?

和自甴很熟 提交于 2019-11-27 15:35:48
the last days I was trying to learn how to access mySQL databases via Java. I am able to load the driver and get a connection to the database ( at least I think so, since I don't get an exception there..) the code is: import java.sql.*; public class test { public static void main(String[] args) { try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); System.out.println("driver loaded..."); } catch(ClassNotFoundException e){ System.out.println("Error in loading the driver..."+e); System.exit(0); } try { Connection dbConnection= DriverManager.getConnection("jdbc:odbc:test","root","password");

PDO returning error “could not find driver” with a known working DSN

佐手、 提交于 2019-11-27 14:45:14
I'm trying to connect to an odbc database via php's PDO class: $dsn = 'odbc:CS_HDZipCodes32bit'; $username = 'demo'; $password = 'skdemo!'; $connection = new PDO($dsn, $username, $password); die( var_dump( $connection ) ); but when I do, I get the error : Fatal error: Uncaught exception 'PDOException' with message 'could not find driver' in C:\inetpub\wwwroot\pdoClass.php:7 Stack trace: #0 C:\inetpub\wwwroot\pdoClass.php(7): PDO->__construct('odbc:CS_HDZipCo...', 'demo', 'skdemo!') #1 {main} thrown in C:\inetpub\wwwroot\pdoClass.php on line 7 The $dsn value is the name of the DSN I created in