本文介绍了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

推荐答案




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

05-29 06:27