If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > can't connect VC++6 to MySQL

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 09-11-04, 14:21
chNC35 chNC35 is offline
Registered User
 
Join Date: Sep 2004
Posts: 1
Question can't connect VC++6 to MySQL

Hello everyone,

I'm pretty new with Visual c++6 but I'm trying to connect to MySQL server with no success.
When I compile my code, I get this error "fatal error C1083: Cannot open include file: 'mysql.h': No such file or directory
Error executing cl.exe."

I did put the file libmySQL.lib in the VC++ lib folder. I have also set the path through tools->options->Directories and then entered the VC++lib folder path. I also went to Project->settings ->links and I entered libmySQL.lib to the Object/Library modules text box.
I'm not sure if libmySQL.lib is the right file to use. I saw some posting where they talk about mysql++.lib as the file to use but I just can't find it anywhere.
Can somedoby help me on this problem??

this is the code that compile and where I get the error message.
#include<stdio.h>
#include<mysql.h>

using namespace std;
#define host "localhost"
#define username "username"
#define password "password"
#define databse "Mydatabse"

MYSQL *conn;

int main()
{

conn = mysql_init(NULL);
mysql_real_connectconn,host,username,password,data bse,0,NULL,0);

MYSQL_RES *res_set;
MYSQL_ROW row;
unsigned int i;

mysql_query(conn,"SELECT * FROM users WHERE userid=1);
res_set = mysql_store_result(conn);
unsigned int numrows = mysql_num_rows(res_set);
while((row=mysql_fetch_row(res_set))!=NULL)
{
for(i=0; i<mysql_num_fields(res_set); i++)
{
printf("%s\n",row[i] != NULL ? row[i] : "NULL");
}
}

mysql_close(conn);
return 0;
}

}
Reply With Quote
  #2 (permalink)  
Old 09-12-04, 11:52
Pat Phelan Pat Phelan is offline
Resident Curmudgeon
 
Join Date: Feb 2004
Location: In front of the computer
Posts: 12,606
When you compile a C program, there are source files (headers like mysql.h) and object files (like libMySQL.lib), and both have to be present to create an executable. You've apparently got the library file, but not the header file.

You probably have to modify either the source code to include the pathname to MySQL.h, or much better need to modify the include files variable to include the directory that contains MySQL.h so that the compiler can find it.

-PatP
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On