c++链接sql 2000出错

来源:百度知道 编辑:UC知道 时间:2024/06/04 08:13:04
BOOL CConnectionDlg::OnInitDialog()
{
CDialog::OnInitDialog();

// Add "About..." menu item to system menu.

// IDM_ABOUTBOX must be in the system command range.
ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
ASSERT(IDM_ABOUTBOX < 0xF000);

CMenu* pSysMenu = GetSystemMenu(FALSE);
if (pSysMenu != NULL)
{
CString strAboutMenu;
strAboutMenu.LoadString(IDS_ABOUTBOX);
if (!strAboutMenu.IsEmpty())
{
pSysMenu->AppendMenu(MF_SEPARATOR);
pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
}
}

// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon

// TODO: Add extra initialization here
// 初始化OLE/COM库环境
::CoInitialize(NULL);

连接字符串最好以标准格式写
"provider=SQLOLEDB;" "Data Source=127.0.0.1;Initial Catalog=UserMan;"
"User Id=sa;Password=sa;";
用SA连接数据库需要设置.一般数据库不允许用sa连接