google-code-export / pyodbc

Automatically exported from code.google.com/p/pyodbc
MIT No Attribution
1 stars 0 forks source link

No results. Previous SQL was not a query. #215

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. cnxn = pyodbc.connect('DRIVER={SQL 
Server};SERVER=<server>;DATABASE=<db>;UID=user;PWD=pass')
2. cursor = cnxn.cursor()
3. cursor.execute("CREATE TABLE dbo.Approvals (ID SMALLINT NOT NULL IDENTITY 
PRIMARY KEY, HostName char(120));")

What is the expected output? What do you see instead?
I was expecting to get some sort of result, especially a new table in my 
database.

What i get: pyodbc.ProgrammingError: No results.  Previous SQL was not a query.

What version of the product are you using? On what operating system?
pyodbc-2.1.11.win32-py2.6
Python2.6
Windows 7
Microsoft SQL Server 2008 (Cluster)
ODBC Drver(s):
   SQL Server
   SQL Server Native Client 10.0

Please provide any additional information below.
I don't know what to say really, it's a strange dead-end problem which no one 
can seam to solve, any help would be appritiated!

Oh, i've tried both a internal SQL account and a Windonws native login both 
with full access and the same result.
I've changed query a couple of times but nothing really helps.

And the syntax Should be 100% perfect, it works if i run the command from a GUI.

Original issue reported on code.google.com by Anton.Do...@gmail.com on 13 Oct 2011 at 12:40

GoogleCodeExporter commented 9 years ago
Is the issues section dead?

Looking back a few threads it sort of looks like it :/
If there's no support here i'll have to change module for the SQL part.

Original comment by Anton.Do...@gmail.com on 14 Oct 2011 at 7:14

GoogleCodeExporter commented 9 years ago
The issues section is not dead - I've just been extremely busy.

I don't know what is causing this.  Have you run the SQL Server unit tests?  
Most of the 160+ tests are going to perform exactly what you are doing, which 
is why it is strange.

I recently had an issue with an out of date ODBC driver.  Installing the 2008R2 
driver fixed it.

Side note: I usually use {SQL Server Native Client 10.0} when connecting to 
2008 since that is the 2008 driver.  The {SQL Server} one is a 2000-compatible 
version.

I just ran your example and it worked as expected.  I'll look into it more 
later, but if this level of functionality didn't work all the time, I'd 
certainly have seen it before.  

Original comment by mkleehammer on 14 Oct 2011 at 10:27

GoogleCodeExporter commented 9 years ago
Can you provide an ODBC trace for this?

Original comment by mkleehammer on 3 Nov 2011 at 1:49

GoogleCodeExporter commented 9 years ago
I am seeing something similar and have submitted issue 243 
(http://code.google.com/p/pyodbc/issues/detail?id=243) with details of how to 
reproduce the problem with a stored procedure.

Original comment by gol...@gmail.com on 5 Mar 2012 at 11:54

GoogleCodeExporter commented 9 years ago
I just ran into the same problem.  Encoding the sql string as ascii solved the 
problem.

Original comment by theserge...@gmail.com on 21 Apr 2012 at 7:13

GoogleCodeExporter commented 9 years ago
Closing because I believe this was fixed in 3.0.5.  Please reopen if you can 
reproduce.  Thanks.

Original comment by mkleehammer on 27 Sep 2012 at 8:35