| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 2129 人关注过本帖
标题:用VC2008连接数据库的程序,总是有错,帮忙看一下。
只看楼主 加入收藏
后会无期99
Rank: 1
等 级:新手上路
帖 子:7
专家分:0
注 册:2012-6-18
结帖率:0
收藏
 问题点数:0 回复次数:0 
用VC2008连接数据库的程序,总是有错,帮忙看一下。
程序代码:
头文件是:
#pragma once
#include <string>
#include <windows.h>
#include ".\mysql-connector-c\include\mysql.h"
#include "..\winxx\ConnectDB.h"
using namespace std;
using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;
namespace winxx {   
    public ref class ConnectDB : public System::Windows::Forms::Form
    {
    private:
        MYSQL * mysql;   
    public:
        ConnectDB(void)
        {
        InitializeComponent();
         }   
    protected:
        ~ConnectDB()
        {
            if (components)
            {
                delete components;
            }
         }
   
        System::Windows::Forms::Button^  button1;

        System::ComponentModel::Container ^components;

#pragma region
        void InitializeComponent(void)
        {
           
            this->button1 = (gcnew System::Windows::Forms::Button());
            this->SuspendLayout();
            //
            // button1
            //
            this->button1->Location = System::Drawing::Point(208, 140);
            this->button1->Name = L"button1";
            this->button1->Size = System::Drawing::Size(75, 23);
            this->button1->TabIndex = 0;
            this->button1->Text = L"button1";
            this->button1->UseVisualStyleBackColor = true;
            this->button1->Click += gcnew System::EventHandler(this, &ConnectDB::button1_Click);
            //
            // ConnectDB
            //
            this->AutoScaleDimensions = System::Drawing::SizeF(6, 12);
            this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
            this->ClientSize = System::Drawing::Size(292, 266);
            this->Controls->Add(this->button1);
            this->Name = L"ConnectDB";
            this->Text = L"ConnectDB";
            this->ResumeLayout(false);
        }
   #pragma endregion
   
    private: System::Void button1_Click(System::Object^  sender, System::EventArgs^  e)
            {
                mysql=mysql_init(NULL);
_mysql=mysql_real_connect(_mysql,"localhost","root","123","mysql",3306,NULL,0);
             }
   
    };
   
}

源文件是:
#include "StdAfx.h"
#include <sstream>
#include "ConnectDB.h"
namespace winxx
{


 Void button1_Click(System::Object^sender,System::EventArgs^  e)
   
   {

           _mysql=mysql_init(NULL);
_mysql=mysql_real_connect(_mysql,"localhost","root","123","mysql",3306,NULL,0);
    }
}
搜索更多相关主题的帖子: 连接数据库 Windows include 
2012-06-19 14:27
快速回复:用VC2008连接数据库的程序,总是有错,帮忙看一下。
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.094957 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved