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 <[EMAIL PROTECTED]>: > > 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@riverbankcomputing.com > http://www.riverbankcomputing.com/mailman/listinfo/pyqt >
_______________________________________________ PyQt mailing list PyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt