Windows平台下c ++中的mysql问题 [英] mysql problem in c++ under windows platform

查看:88
本文介绍了Windows平台下c ++中的mysql问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在代码项目成员的帮助下,我了解了C编程中的ado连接..

但是问题在于程序提供了正常的终止..

我的编码是:


#include"stdafx.h"
#include< windows.h>
#include< stdio.h>

#import"C:\ Program Files \ Common Files \ System \ ADO \ msado15.dll"重命名("EOF","EndOfFile")

struct StartOLEProcess {
StartOLEProcess(){
:: CoInitialize(NULL);
}
〜StartOLEProcess(){
:: CoUninitialize();
} [ ]
} _start_StartOLEProcess;

//连接字符串
ADODB :: _ ConnectionPtr Con = NULL;

//记录集

ADODB :: __ RecordsetPtr RecSet = NULL;

//单个字段指针

ADODB :: FieldPtr字段;

//记录受影响的指针

VARIANT * RecordsAffected = NULL;

//导入Ole变量

StartOLEProcess OLEVar;

int main(int argc,char * argv [])
{
if(Con.CreateInstance(__ uuidof(ADODB :: Connection))== 0)
{
printf("sucess \ n");

}
Con-> ConnectionString ="Driver = {MySQL ODBC 3.51 Driver}; Server = MyRemoteHost;""Port = 3306; Option = 4; Database = db; Uid = root; Pwd ="";;
Con-> ConnectionTimeout = 30;

Con-> Open(",",",0);

printf("hai \ n");
返回0;
}

我的数据库是mysql ..
数据库名称是db1
我的用户名是root;
和密码都不是..

那是什么问题..为什么会产生错误

Form the help of code project members i learn about the ado connection in the c programming..

but the problem is that the program provide the up normal Termination..

my coding is:


#include "stdafx.h"
#include <windows.h>
#include <stdio.h>

#import "C:\Program Files\Common Files\System\ADO\msado15.dll" rename("EOF", "EndOfFile")

struct StartOLEProcess{
StartOLEProcess( ) {
::CoInitialize(NULL);
}
~StartOLEProcess( ) {
::CoUninitialize( );
}[]
} _start_StartOLEProcess;

//connection string
ADODB::_ConnectionPtr Con = NULL;

//record set

ADODB::_RecordsetPtr RecSet = NULL;

//single Field Pointer

ADODB::FieldPtr Field;

//Record affected pointer

VARIANT *RecordsAffected = NULL;

//importing Ole variable

StartOLEProcess OLEVar;

int main(int argc, char* argv[])
{
if(Con.CreateInstance(__uuidof(ADODB::Connection)) == 0)
{
printf("sucess\n");

}
Con->ConnectionString = "Driver={MySQL ODBC 3.51 Driver};Server=MyRemoteHost;""Port=3306;Option=4;Database=db;Uid=root;Pwd=""";
Con->ConnectionTimeout = 30;

Con->Open("","","",0);

printf("hai\n");
return 0;
}

my database is mysql..
database name is db1
my user name is root;
and password is nothing..

what is the wrong in that .. why it producing error

推荐答案

否.

您是否已安装MySQL和
No.

Have you installed MySQL and the MySql Connector C++[^]?


我认为您必须提供参考到头文件之一,以使sql语句正常工作.我找到了这个网站,它不使用mysql.h而是一个不同的头文件.希望这是有益的.

http://www.enderunix.org/documents/eng/mysql++.html [ ^ ]

该网站还显示了如何为C ++安装MySQL.因此,这应该给您一个开始,也许您也可以获取自己的MySQL.h文件


让我知道它是否有效.我自己还没有测试过.

-
AJ
I think you have to give reference to one of the header files in order to get the sql statements working. I found this website, where it does not use mysql.h but a different header file. Hope this is helful.

http://www.enderunix.org/documents/eng/mysql++.html[^]

This website also shows how to install MySQL for C++. So that should give you a start and may be you can also get your MySQL.h file


Let me know if it worked. I have not tested it myself though.

--
AJ


检入安装SDK的目录树.可能应该有一个名为 include 的子目录,它将保存头文件.只需将该目录名称添加到您的包含搜索路径即可.
Check in the directory tree that the SDK was installed into. There should probably be a subdirectory called include which will hold the header file. Just add that directory name to your include search path.


这篇关于Windows平台下c ++中的mysql问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆