the code:
QString conn
= "Data Source=.\\SQLEXPRESS;Initial Catalog=master;Integrated Security=False;Persist Security Info=False;" "User ID=sa;password=[]";
db.setDatabaseName(conn);
db.setUserName("sa");
db.setPassword("[]");
if (!db.open())
error = db.lastError().text();
QString error;
QString conn = "Data Source=.\\SQLEXPRESS;Initial Catalog=master;Integrated Security=False;Persist Security Info=False;"
"User ID=sa;password=[]";
QSqlDatabase db = QSqlDatabase::addDatabase("QODBC", "MainDBConnection");
db.setDatabaseName(conn);
db.setUserName("sa");
db.setPassword("[]");
if (!db.open())
error = db.lastError().text();
To copy to clipboard, switch view to plain text mode
but it not works, error == "[Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified QODBC3: Unable to connect"
while following run, when i use mssql 2005 enterprise edition.
conn
= QString::fromLocal8Bit("DRIVER={SQL SERVER};SERVER=192.168.10.96;DATABASE=master;Uid=sa;Pwd=[]");
db.setDatabaseName(conn);
db.setUserName("sa");
db.setPassword("[]");
conn = QString::fromLocal8Bit("DRIVER={SQL SERVER};SERVER=192.168.10.96;DATABASE=master;Uid=sa;Pwd=[]");
QSqlDatabase db = QSqlDatabase::addDatabase("QODBC", "MainDBConnection");
db.setDatabaseName(conn);
db.setUserName("sa");
db.setPassword("[]");
To copy to clipboard, switch view to plain text mode
thx!
Bookmarks