Qt 访问 MS Access 数据库 open error!

fetionone 2010-10-31 10:02:57
Ubuntu 9.10
qtsdk-2010.02

访问 MS Access 数据库
代码:
#include <QtCore/QCoreApplication>
#include <QtSql>
#include <QDebug>

int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);

QSqlDatabase dbAc = QSqlDatabase::addDatabase("QODBC");
qDebug() << "ODBC driver valid?" << dbAc.isValid();

dbAc.setDatabaseName(QString("DRIVER={Microsoft Access Driver (*.mdb)};FIL={MS Access};DBQ=Files.mdb;UID=;PWD="));

qDebug()<<dbAc.databaseName();

if ( !dbAc.open("",""))
{ qDebug()<<"DB open error!"; }
else
{ qDebug()<<"DB open Sucess!"; }


return a.exec();
}


数据库打不开:

运行结果:
ODBC driver valid? true
"DRIVER={Microsoft Access Driver (*.mdb)};FIL={MS Access};DBQ=Files.mdb;UID=;PWD="
DB open error!

请问这是什么原因啊???

多谢了
...全文
77 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
dext 2010-11-01
  • 打赏
  • 举报
回复

#include <qapplication.h>
#include <qsqldatabase.h>
#include <qsqlquery.h>

#define DB_NaSCoM_DRIVER "QODBC3"
#define DB_NaSCoM_DBNAME "manoj"
#define DB_NaSCoM_USER "scicom"
#define DB_NaSCoM_PASSWD ""
#define DB_NaSCoM_HOST "hpstryker"

int main( int argc, char *argv[] )
{
QApplication app ( argc, argv, FALSE );

QSqlDatabase *defaultDB = QSqlDatabase::addDatabase(
DB_NaSCoM_DRIVER );
defaultDB->setDatabaseName( DB_NaSCoM_DBNAME );
defaultDB->setUserName( DB_NaSCoM_USER );
defaultDB->setPassword( DB_NaSCoM_PASSWD );
defaultDB->setHostName( DB_NaSCoM_HOST );

if ( defaultDB->open() ) {
// Database successfully opened; we can now issue SQL
commands.
QSqlQuery query(QString::null, defaultDB);
query.exec ("SELECT * FROM igifile");
if ( query.isActive()) {
While (query.next ()) {
qDebug (query.value (1).toString() + ": " +
query.value (2).toString ());
}
}
}
return 0;
}

网管教程 从入门到精通软件篇 ★一。★详细的xp修复控制台命令和用法!!! 放入xp(2000)的光盘,安装时候选R,修复! Windows XP(包括 Windows 2000)的控制台命令是在系统出现一些意外情况下的一种非常有效的诊断和测试以及恢复系统功能的工具。小编的确一直都想把这方面的命令做个总结,这次辛苦老范给我们整理了这份实用的秘笈。   Bootcfg   bootcfg 命令启动配置和故障恢复(对于大多数计算机,即 boot.ini 文件)。   含有下列参数的 bootcfg 命令仅在使用故障恢复控制台时才可用。可在命令提示符下使用带有不同参数的 bootcfg 命令。   用法:   bootcfg /default  设置默认引导项。   bootcfg /add    向引导列表中添加 Windows 安装。   bootcfg /rebuild  重复全部 Windows 安装过程并允许用户选择要添加的内容。   注意:使用 bootcfg /rebuild 之前,应先通过 bootcfg /copy 命令备份 boot.ini 文件。   bootcfg /scan    扫描用于 Windows 安装的所有磁盘并显示结果。   注意:这些结果被静态存储,并用于本次会话。如果在本次会话期间磁盘配置发生变化,为获得更新的扫描,必须先重新启动计算机,然后再次扫描磁盘。   bootcfg /list   列出引导列表中已有的条目。   bootcfg /disableredirect 在启动引导程序中禁用重定向。   bootcfg /redirect [ PortBaudRrate] |[ useBiosSettings]   在启动引导程序中通过指定配置启用重定向。   范例: bootcfg /redirect com1 115200 bootcfg /redirect useBiosSettings   hkdsk   创建并显示磁盘的状态报告。Chkdsk 命令还可列出并纠正磁盘上的错误。   含有下列参数的 chkdsk 命令仅在使用故障恢复控制台时才可用。可在命令提示符下使用带有不同参数的 chkdsk 命令。   vol [drive:] [ chkdsk [drive:] [/p] [/r]   参数  无   如果不带任何参数,chkdsk 将显示当前驱动器中的磁盘状态。 drive: 指定要 chkdsk 检查的驱动器。 /p   即使驱动器不在 chkdsk 的检查范围内,也执行彻底检查。该参数不对驱动器做任何更改。 /r   找到坏扇区并恢复可读取的信息。隐含着 /p 参数。   注意 Chkdsk 命令需要 Autochk.exe 文件。如果不能在启动目录(默认为 %systemroot%System32)中找到该文件,将试着在 Windows 安装 CD 中找到它。如果有多引导系统的计算机,必须保证是在包含 Windows 的驱动器上使用该命令。 Diskpart   创建和删除硬盘驱动器上的分区。diskpart 命令仅在使用故障恢复控制台时才可用。   diskpart [ /add |/delete] [device_name |drive_name |partition_name] [size]   参数 无   如果不带任何参数,diskpart 命令将启动 diskpart 的 Windows 字符模式版本。   /add   创建新的分区。   /delete   删除现有分区。   device_name   要创建或删除分区的设备。设备名称可从 map 命令的输出获得。例如,设备名称:   DeviceHardDisk0   drive_name   以驱动器号表示的待删除分区。仅与 /delete 同时使用。以下是驱动器名称的范例:   D:   partition_name   以分区名称表示的待删除分区。可代替 drive_name 使用。仅与 /delete 同时使用。以下是分区名称的范例:   DeviceHardDisk0Partition1    大小   要创建的分区大小,以兆字节 (MB)表示。仅与 /add 同时使用。   范例   下例将删除分区: diskpart /delete Device HardDisk0 Partition3 diskpart /delete F:   下例将在硬盘上添加一个 20 MB 的分区:   diskpart /add Device HardDisk0 20   Fixboot
建伍378G写频软件,压包内有: KPG-56D Help File Version 3.00 File name: KPG56D_6.HLP Read From Radio Help This function reads all program data from the transceiver flash memory. 1. When "Read from radio" is selected, the "Read from radio" window opens. 2. Select "[OK]" or "[Cancel]". Note1: If communication with the transceiver is not possible for any reason, the "Check Connection Error" window open. Confirm that the transceiver is correctly connected to the computer via a KPG-22/46 cable, then select "[Retry]". Write To Radio Help This function writes data into the transceiver flash memory. 1. When "Write to radio" is selected, the "Write to radio" window opens. 2. Select "[OK]" or "[Cancel]". "[OK]" writes data into the transceiver. "[Cancel]" aborts the write function and re-displays the Program menu. Note1: If communication with the transceiver is not possible for any reason, the "Check Connection Error" window opens. Confirm that the transceiver is correctly connected to the computer via a KPG-22/46 cable, then select "[Retry]". Read to Trunking Board Help This function reads trunking data from the trunking board's EEPROM. 1. When "Read from trunking board" is selected, the "Read from Trunking Board" window opens. 2. When "[OK]" is selected, the "Input Password" window opens. 3. Enter the "Five Digit Access Code", then press [Enter]. Note 1: If communication with the transceiver is not possible for any reason, the "Check Connection Error" window opens. Confirm that the transceiver is correctly connected to the computer via a KPG-22/46 cable, then select "[Retry]". Write to Trunking Board Help This function writes trunking data to the trunking board's EEPROM. 1. When "Write to trunking board" is selected, the "Write to trunking board" window opens. 2. When "[OK]" is selected, the "Input Password" window opens. 3. Enter the "Five Digit Access Code", then press [Enter]. Note 1: If communication with the transceiver is not possible for any reason, the "Check Connection Error" window opens. Confirm that the transceiver is correctly connected to the computer via a KPG-22/46 cable, then select "[Retry]". Trunking Deviation Help Trunking Deviation is used to set the transmit modulation level from SmarTrunk Module. The alignment mode transmit frequency will be the first channel in the currently selected channel group on the transceiver. This mode will generate the DTMF digit 9 on the transmit frequency. Using a small slotted alignment tool, adjust the level pot on the SmarTrunk Module for a level of 2/3 of maximum deviation(3.3kHz on a 5 kHz system). NOTE: Select the trunking channel group on the transceiver manually before enter the Alignment Mode. "SmarTrunk & SmarTrunk II are registered trademarks of SmarTrunk Systems, Inc., Hayward, California, U.S.A.". Firmware Program Help This function writes the main program to the transceiver. When you select this function, the software that writes the main program to the transceiver (FPRO.EXE (Firmware Programming Software)) is activated. The Fpro startup screen appears first. Press any key to progress to the Fpro Main screen. In the Main screen, select the baud rate (bps) and the Firmware File (HEX File), then press [F10] to start the program. The software then starts writing the main program to the transceiver flash memory. Use this function for tasks such as upgrading the transceiver. (See Service Manual for details) -- select & press [ENTER]. Check Sum Help This function displays the Check sum of the main program which was written in firmware Program. ESN Help This function displays the Electronic Serial Number. This function was newly designed, so it will be available on radios that have the following or larger serial numbers. S/No. 203XXXXX- Frequency Channel Help Select one of the pre-programmed test frequencies. The transceiver is set to the RF Power Low. The transceiver will display the "LO"(Portable)/ "AUX"(Mobile) indicator. Press the up- or down-arrow keys to increase or decrease the channel frequency or enter the desired channel frequency with the keyboard, then press [Enter]. (See the Service Manual for details) Signalling Tone Help Select one of the pre-programmed Signalling formats. Press the up- or down-arrow keys to increase or decrease the Signalling Tone number or enter the desired Signalling Tone number with the keyboard, then press [Enter]. (See the Service Manual for details) Wide/Narrow Help (M,K,C TYPE) First tune all items in the wide mode. Then tune QT VCO BAL. QT TCXO BAL. DQT VCO BAL. DQT TCXO BAL. MAX DEV. DQT BAL. QT Fine DEV. DQT Fine DEV. DTMF DEV. TONE DEV. SQ. in the narrow mode. Select "Wide" or "Narrow" for the Test mode using the up or down keys. When narrow is selected, the dot mark "." displayed at the extreme right of transceiver display. (E TYPE) First tune all item in the wide 5k mode. Then tune QT VCO BAL. QT TCXO BAL. DQT VCO BAL. DQT TCXO BAL. MAX DEV. DQT BAL. QT Fine DEV. DQT Fine DEV. DTMF DEV. TONE DEV. SQ. in the wide 4k mode. Select "W5k" or "W4k" for the Test mode using the up or down keys. When narrow is selected, the dot mark "." displayed at the extreme right of transceiver display. Frequency Adjustment Help Preset TX Frequency (precise) adjustment. Connect measuring devices to the transceiver and adjust the Carrier Frequency. Note: While adjusting, "FREQ ***" appears on the transceiver display. Range : 1 to 256 (steps of 1) Default: Last Adjustment Press the right- or left-arrow key to increase or decrease setting. Press [Enter] to store the specified data in the transceiver. (See Service Manual for details) RF High Power Help Preset RF Power High level adjustment. This feature has 5 adjustment points to compensate for in-band frequency. Press tab key to change frequency. Connect measuring devices to the transceiver and adjust the power. Note: While adjusting, "HPOW ***" appears on the transceiver display. Range : 1 to 256 (steps of 1) Default: Last Adjustment Press the right- or left-arrow key to increase or decrease setting. Press [Enter] to store the specified data in the transceiver. (See Service Manual for details) RF Low Power Help Preset RF Power Low level adjustment. This feature has 5 adjustment points to compensate for in-band frequency. Press tab key to change frequency. Connect measuring devices to the transceiver and adjust the power. Note: While adjusting, "LPOW ***" appears on the transceiver display. Range : 1 to 256 (steps of 1) Default: Last Adjustment Press the right- or left-arrow key to increase or decrease setting. Press [Enter] to store the specified data in the transceiver. (See Service Manual for details) Max Deviation Help Preset Maximum Deviation level adjustment. This feature has 3 adjustment points to compensate for in-band frequency. Press tab key to change frequency. Tone (1 kHz) injection is required through an optional cable. Connect measuring devices to the transceiver and adjust the Maximum Deviation level. Note: While adjusting, "MAX ***" appears on the transceiver display. Range : 1 to 256 (steps of 1) Default: Last Adjustment Press the right- or left-arrow key to increase or decrease setting. Press [Enter] to store the specified data in the transceiver. (See Service Manual for details) DQT Balance Help Preset DQT encode balance adjustment. This feature has 3 adjustment points to compensate for in-band frequency.(Mobile) Press tab key to change frequency.(Mobile) Connect measuring devices to the transceiver and adjust the wave form. Note: While adjusting, "BAL ***" appears on the transceiver display. Range : 1 to 256 (steps of 1) Default: Last Adjustment Press the right- or left-arrow key to increase or decrease setting. Press [Enter] to store the specified data in the transceiver. (See Service Manual for details) QT Fine Deviation Help Preset QT encode level adjustment. This feature has 3 adjustment points to compensate for in-band frequency. Press tab key to change frequency. Connect measuring devices to the transceiver and adjust the QT encode level. Note: While adjusting, "FQT ***" is displayed on the transceiver. Range : 1 to 256 (steps of 1) Default: Last Adjustment Press the right- or left-arrow key to increase or decrease setting. Press [Enter] to store the specified data in the transceiver. (See Service Manual for details) DQT Fine Deviation Help Preset DQT encode level adjustment. This feature has 3 adjustment points to compensate for in-band frequency. Press tab key to change frequency. Connect measuring devices to the transceiver and adjust the DQT encode level. Note: While adjusting, "FDQT ***" appears on the transceiver display. Range : 1 to 256 (steps of 1) Default: Last Adjustment Press the right- or left-arrow key to increase or decrease setting. Press [Enter] to store the specified data in the transceiver. (See Service Manual for details) DTMF Fine Deviation Help Preset DTMF encode level adjustment. Connect measuring devices to the transceiver and adjust the DTMF encode level. Note: While adjusting, "DTMF ***" appears on the transceiver display. Range : 1 to 256 (steps of 1) Default: Last Adjustment Press the right- or left-arrow key to increase or decrease setting. Press [Enter] to store the specified data in the transceiver. (See Service Manual for details) Single Tone Fine Deviation Help Preset Single Tone encode level adjustment. Connect measuring devices to the transceiver and adjust the Single Tone encode level. Note: While adjusting, "TONE ***" appears on the transceiver display. Range : 1 to 256 (steps of 1) Default: Last Adjustment Press the right- or left-arrow key to increase or decrease setting. Press [Enter] to store the specified data in the transceiver. (See Service Manual for details) Sensitivity Help Preset the Sensitivity level adjustment. This feature has 3 adjustment points to compensate for in-band frequency. Press tab key to change the frequency. (See the Service Manual for details) Note: While adjusting, "SENS ***" appears on the transceiver display. Range : 1 to 256 (steps of 1) Default: Last Adjustment Press the right- or left-arrow key to increase or decrease the setting. Press [Enter] to store the specified data in the transceiver. (See the Service Manual for details) Squelch(Tight) Help "Squelch(Tight)" is the squelch level 9 adjustment. Refer "Squelch level" in Optional Features screen. This feature has 3 adjustment points to compensate for in-band frequency.(Mobile) Press tab key to change frequency.(Mobile) Connect measuring devices to the transceiver and adjust the Preset Squelch Sensitivity. Note: While adjusting, "SQL9 ***" appears on the transceiver display. Range : 1 to 256 (steps of 1) Default: Last Adjustment Press the right- or left-arrow key to increase or decrease setting. Press [Enter] to store the specified data in the transceiver. (See Service Manual for details) Squelch(Open) Help "Squelch(Open)" is the squelch level 3 adjustment. This feature has 3 adjustment points to compensate for in-band frequency.(Mobile) Press tab key to change frequency.(Mobile) Connect measuring devices to the transceiver and adjust the Preset Squelch Sensitivity. Note: While adjusting, "SQL3 ***" appears on the transceiver display. Range : 1 to 256 (steps of 1) Default: Last Adjustment Press the right- or left-arrow key to increase or decrease setting. Press [Enter] to store the specified data in the transceiver. (See Service Manual for details) Print Tuning Data Help Print out currently memorized tuning data. Press [F5] to print out the tuning data. Battery Warning Level Help Preset the Battery Warning Level adjustment. Connect the appropriate measuring device to the transceiver and adjust the Battery Warning Voltage. While adjusting, "BATT ***" appears on the transceiver display. The table below shows the relationship between Low Voltage Warning and Battery Condition. Low Voltage Warning Battery Condition The red LED flashes The battery voltage is low but during transmission. the transceiver is still usable. The red LED flashes and The battery voltage is low and a continuous beep tone the transceiver is not usable sounds while pressing the PTT. to make calls. Range : 1 to 256 (steps of 1) Default: Last Adjustment Press [F2] or [SPACE BAR] to transmit, adjust the voltage during transmission and adjust the Battery Warning Level. Press [Enter] to store the specified data in the transceiver. (See the Service Manual for details) QT VCO Balance Help Preset QT VCO Balance adjustment. This feature has 3 points adjustment to compensate an in band frequency. Press tab key to change frequency. Connect measuring devices to the transceiver and adjust the wave form. Note: While adjusting, "VQT ***" appears on the transceiver display. Range : 1 to 256 (steps of 1) Default: Last Adjustment Press the right- or left-arrow key to increase or decrease setting. Press [Enter] to store the specified data in the transceiver. (See Service Manual for details) QT TCXO Balance Help Preset QT TCXO Balance adjustment. This feature has 3 adjustment points to compensate for in-band frequency. Press tab key to change frequency. Connect measuring devices to the transceiver and adjust the wave form. Note: While adjusting, "XQT ***" appears on the transceiver display. Range : 1 to 256 (steps of 1) Default: Last Adjustment Press the right- or left-arrow key to increase or decrease setting. Press [Enter] to store the specified data in the transceiver. (See Service Manual for details) DQT VCO Balance Help Preset DQT VCO Balance adjustment. This feature has 3 adjustment points to compensate for in-band frequency. Press tab key to change frequency. Connect measuring devices to the transceiver and adjust the wave form. Note: While adjusting, "VDQT ***" appears on the transceiver display. Range : 1 to 256 (steps of 1) Default: Last Adjustment Press the right- or left-arrow key to increase or decrease setting. Press [Enter] to store the specified data in the transceiver. (See Service Manual for details) DQT TCXO Balance Help Preset DQT TCXO Balance adjustment. This feature has 3 adjustment points to compensate for in-band frequency. Press tab key to change frequency. Connect measuring devices to the transceiver and adjust the wave form. Note: While adjusting, "XDQT ***" appears on the transceiver display. Range : 1 to 256 (steps of 1) Default: Last Adjustment Press the right- or left-arrow key to increase or decrease setting. Press [Enter] to store the specified data in the transceiver. (See Service Manual for details) Communication Port Help Select either COM1 or COM2 as the port for communicating with the transceiver. If the computer has only one communication port, the port is automatically set to COM1. 1. When "Communication port" is selected, the "Communication Port" window opens. If there is only a COM1 port on your computer, a window opens to report this fact. In this case, the communication port cannot be changed. 2. Select either "[COM1]" or "[COM2]". 3. Press [Esc] to complete the setting and restore the Channel Information window. Black & White Color Help Monochrome display mode. -- select & press [ENTER]. Display Back Color Help Background color of main window Selectable: Blue, Green, Cyan, Red, Magenta, Brown, Lightgray, Black Default : Blue Select the desired value by pressing [SPACE BAR], [Shift]+[SPACE BAR], [F2], or [Shift]+[F2]. Input Data Color Help Input data cursor color. Selectable: Blue, Green, Cyan, Red, Magenta, Brown, Lightgray, Black Default : Brown Select the desired value by pressing [SPACE BAR], [Shift]+[SPACE BAR], [F2], or [Shift]+[F2]. Feature Highlight Color Help Cursor background color of selected function or parameter. Selectable: Blue, Green, Cyan, Red, Magenta, Brown, Lightgray, Black Default : Magenta Select the desired value by pressing [SPACE BAR], [Shift]+[SPACE BAR], [F2], or [Shift]+[F2]. Screen Border Info. Color Help Border information background color of main window. Selectable: Blue, Green, Cyan, Red, Magenta, Brown, Lightgray, Black Default : Green Select the desired value by pressing [SPACE BAR], [Shift]+[SPACE BAR], [F2], or [Shift]+[F2]. Windows Menu Color Help Main menu bar sub window (File, Model, Edit, Program, Setup, F1-Help) background color. Selectable: Blue, Green, Cyan, Red, Magenta, Brown, Lightgray, Black Default : Cyan Select the desired value by pressing [SPACE BAR], [Shift]+[SPACE BAR], [F2], or [Shift]+[F2]. General Message Color Help Important information (such as Warning Message or Error Message) window background color. Selectable: Blue, Green, Cyan, Red, Magenta, Brown, Lightgray, Black Default : Red Select the desired value by pressing [SPACE BAR], [Shift]+[SPACE BAR], [F2], or [Shift]+[F2]. Windows Color Help Sub menu bar, sub window background color. Selectable: Blue, Green, Cyan, Red, Magenta, Brown, Lightgray, Black Default : Lightgray Select the desired value by pressing [SPACE BAR], [Shift]+[SPACE BAR], [F2], or [Shift]+[F2]. Help Window Color Help Help window background color. Selectable: Blue, Green, Cyan, Red, Magenta, Brown, Lightgray, Black Default : Lightgray Select the desired value by pressing [SPACE BAR], [Shift]+[SPACE BAR], [F2], or [Shift]+[F2]. Help Path Help Use Help path to select the drive and path name of the Help file. The Help file is called KPG56D.HLP and is automatically loaded in the same folder as the program file upon using the Install command for installation. 1. When selecting "Help path", the "Drive & Path" window opens. 2. Type the drive and path name, then press [Enter]. The window closes and the Channel Information window opens. If the entered drive does not contain a disk, an error message appears. Press any key, insert the correct disk in the specified drive, then press [Enter]. If the entered drive or path does not exist, an error message appears. Press any key, correct the entered drive or path name, then press [Enter]. If the Help file is not found under the selected drive and path name, an error message appears. Press any key, correct the drive and path names, then press [Enter]. Note: The Help file can be moved to the directory of your choice. FPRO Path Help Use "Fpro path" to select the drive and path name of the Fpro File program named "FPRO.EXE". If an incorrect drive or path name is entered, the program will not correctly initiate. Note1: If the entered drive does not contain a disk, an error message appears. Press any key, insert the correct disk in the specified drive, then press [Enter]. Note2: If the entered drive or path does not exist, an error message appears. Press any key, correct the entered drive or path name, then press [Enter]. Note3: If the "FPRO.EXE" program is not found under the selected drive and path name, an error message appears. Press any key, correct the drive and path names, then press [Enter]. End Of Help File

16,216

社区成员

发帖
与我相关
我的任务
社区描述
Qt 是一个跨平台应用程序框架。通过使用 Qt,您可以一次性开发应用程序和用户界面,然后将其部署到多个桌面和嵌入式操作系统,而无需重复编写源代码。
社区管理员
  • Qt
  • 亭台六七座
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧