[PyQt] mem error in windows
Kermit
stef.kermit at gmail.com
Thu Mar 6 17:17:02 GMT 2008
hi,
try this for connection
db= QSqlDatabase.addDatabase("QODBC")
connectionString = "DRIVER={SQL Server};SERVER=localhost;UID=myuser;PWD=
mypassw;DATABASE=dnsMySQL;"
db.setDatabaseName(connectionString)
if not db.open():
print db.lastError().text()
sys.exit(1)
Kermit
2008/3/6, Mario Daniel Carugno <carugnom at gmail.com>:
>
> Hi, i've installed pyqt4 + python2.5 in windows, and wrote a small script
> to test ODBC access to
> a MySQL table. The script is:
>
> from PyQt4 import QtSql
> import sys
>
> db = QtSql.QSqlDatabase.addDatabase("QODBC")
> db.setDatabaseName("dnsMySQL")
> db.setHostName("localhost")
> db.setUserName("myuser")
> db.setPassword("mypassw")
>
> if not db.open():
> txt = db.lastError().text()
> print unicode(txt)
> sys.exit()
>
> qry = QtSql.QSqlQuery()
> qry.exec_( "select id from mytable where id = 20" )
>
> if qry.next():
> a = qry.value(0).toInt()
> print a
>
> I run it and executes (it prints the value of a) but then the following
> error appears:
>
> the instruction at "0x00ea2acf" referenced memory at "0x01013f20". The
> memory could not be "read".
>
> What's the problem ? Any idea ?
>
> Thanks
>
>
>
> _______________________________________________
> PyQt mailing list PyQt at riverbankcomputing.com
> http://www.riverbankcomputing.com/mailman/listinfo/pyqt
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20080306/422293a5/attachment.html
More information about the PyQt
mailing list