473,396 Members | 1,892 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

mysql_init() initialization problem

hi,
when i try to call the mysql_init function it is not getting initilized properly.
can someone help me

thanks
chinmay
Jul 23 '05 #1
1 3047
sh*********@gmail.com (Chinmay Shah) wrote in message news:<d9**************************@posting.google. com>...
hi,
can someone help me pleaseeeeee? i am attempting to connect mysql server to win32 application... as far
as initialization is concerned, it is successful but its showing some
problem when i use mysql_real_connect..... have used different
combinations to try and connect but all are unsuccessful... here is
the code which i have written.... is there any mistake in the code...
do let me know??????

the code is:

#include<winsock.h>
#include<my_global.h>
#include<mysql.h>
#include<windows.h>
#include<windowsx.h>

void ConnectToMySql()
{
MYSQL mysql;

char *mysql_host = "localhost";
char *mysql_user = "root";
char *mysql_pass = "";
char *mysql_db = "test";
int mysql_port = 3306;
int mysql_flag = 0;
char *mysql_unix = NULL;

//Allocates or initializes a MYSQL object
if(mysql_init(&mysql))
MessageBox(g_hWnd,"Initialization Successful","Testing",0);
else
MessageBox(g_hWnd,"Initialization Not Successful","Testing",0);

//attempts to establish a connection to a MySQL database engine
running on host
if(!mysql_real_connect
(&mysql,MYSQL_HOST,MYSQL_USER,MYSQL_PASSWORD,MYSQL _DB,MYSQL_PORT,MYSQL_SOCKET,MYSQL_FLAG))
MessageBox(g_hWnd,"Connection 1 Not Successful","Test",0);

if(!mysql_real_connect(&mysql,mysql_host,mysql_use r,mysql_pass,mysql_db,mysql_port,mysql_unix,mysql_ flag))
MessageBox(g_hWnd,"Connection 2 Not Successful","Test",0);

if(!mysql_real_connect(&mysql,"localhost","root"," ","test",3306,NULL,0))
MessageBox(g_hWnd,"Connection 3 Not Successful","Test",0);

if(!mysql_real_connect(&mysql,"localhost","","","" ,0,NULL,0))
MessageBox(g_hWnd,"Connection 4 Not Successful","Test",0);

if(!mysql_real_connect(&mysql,"localhost","root"," ","test",0,NULL,0))
MessageBox(g_hWnd,"Connection 5 Not Successful","Test",0);

if(!mysql_real_connect(&mysql,"","","","",0,NULL,0 ))
MessageBox(g_hWnd,"Connection 6 Not Successful","Test",0);

if(!mysql_real_connect(&mysql,"localhost","root"," ","",0,NULL,0))
MessageBox(g_hWnd,"Connection 7 Not Successful","Test",0);
}
do let me at the earliest...
thanks
chinmay

Jul 23 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Vinay Aggarwal | last post by:
I have been thinking about the lazy initialization and double checked locking problem. This problem is explain in detail here http://www.cs.umd.edu/~pugh/java/memoryModel/DoubleCheckedLocking.html...
4
by: Russell Silva | last post by:
I have a class A with a member variable type vector<foo> which is initialized upon construction (no standard () constructor): class A { protected: vector<foo> foo_vector; public: A(const...
3
by: DanielBradley | last post by:
Hello all, I have recently been porting code from Linux to cygwin and came across a problem with static const class members (discussed below). I am seeking to determine whether I am programming...
10
by: JKop | last post by:
What's the difference between them? Take the following: #include <iostream> struct Blah { int k;
4
by: Anton Pervukhin | last post by:
Hi everybody! I have a small problem regarding the initialization of pointer to the file stream under some conditions. Imagine a class which has a pointer to output file stream and some...
49
by: Luke Meyers | last post by:
Lately I find myself increasingly preferring the practice of going ever-so-slightly out of my way to avoid the use of the form of initialization which uses the '=' symbol, on the grounds that it...
5
by: Jesper Schmidt | last post by:
When does CLR performs initialization of static variables in a class library? (1) when the class library is loaded (2) when a static variable is first referenced (3) when... It seems that...
3
by: Steve Folly | last post by:
Hi, I had a problem in my code recently which turned out to be the 'the "static initialization order fiasco"' problem (<http://www.parashift.com/c++-faq-lite/ctors.html#faq-10.12>) The FAQ...
11
by: subramanian100in | last post by:
Suppose we have a class named Test. Test obj; // assuming default ctor is available Test direct_init(obj); // direct initialization happens here Test copy_init = obj; // copy initialization...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.