|
Using MFC / C++ with ADO accessing a MySQL database. I have in one table a column type TEXT. It seems however that the ActiveX or the MySQL driver (not sure which) is identifying that column as “adVarChar” instead of what I expected it to be “adLongVarChar” and subsequently, the process ends up with wrong data buffer.
Should I use maybe another data type for long text colimns?
Cheers
Alex
|
|
|
|
|
sorry my english.
hi guys.
i use mysql and visual c++. today i try remote connect mysql server. but i can't mysql server support localhost, it's not enough .
my client application must be remote!!!
how can i connect to mysql server.
PLZ HELP ME!!!
sorry my english.
naya l baina
|
|
|
|
|
Think we found a bug. Each query creates a new connection to the Server in
*sql_connection_c::grabdb()
Your code:
OPENDB *sql_connection_c::grabdb()
{
OPENDB *odb;
for ( odb = opendbbase; odb; odb = odb->next )
{
if ( !odb->busy )
{
break;
}
}
...
...
else
{
odb->busy++; // <- That could also be a Problem because you have to count this down at
} // the end of the query to prevent an overflow of "busy"
return odb;
}
*****************************************************************
Fixed code:
OPENDB *sql_connection_c::grabdb()
{
OPENDB *odb;
for ( odb = opendbbase; odb; odb = odb->next )
{
//if ( !odb->busy )
if(odb)
{
break;
}
}
...
...
}
Fixed "busy":
It should be better to manage "busy" here:
int sql_query_c::execute( char *sql )
{
if ( sql_connection && odb && !res )
{
odb->busy++;
if ( try_execute( sql ) )
{
res = mysql_store_result( &odb->mysql );
odb->busy--;
}
}
return (int)res;
}
|
|
|
|
|
#include <winsock2.h>
That's for wincrap if I'm not mistaken...
But that's a project about databases.. who the %/$% runs databases on personal computers?!?
Anyone knows of a solution for linux???
MJ
|
|
|
|
|
Can anyone tell me how to get the row value from a table by using function in mysqlplus.h?
|
|
|
|
|
No kidding, I don't get this. Does this really work.
Has anyone got it working at all. Please show some simple code.
|
|
|
|
|
OK, here is a sample I got working after hours of hell.
Hope this helps someone
Basically prints out the column/field names
Then prints out each row at each column
========================================
<br />
#include "mysqlplus.h"<br />
#include <STDIO.H><br />
<br />
#include <iostream><br />
<br />
<br />
void main()<br />
{<br />
sql_connection_c connection( "myDatabase", <br />
"localhost", "user", "password" );<br />
sql_query_c query( &connection );<br />
sql_result_c *sql_result = 0;<br />
if ( !query.execute( "select * from data" ) )<br />
{<br />
printf( "oops... didn't execute!!\n" );<br />
return;<br />
}<br />
int idx = 0;<br />
sql_result = query.store();<br />
int n_fields = sql_result->n_fields();<br />
<br />
__int64 nRows = sql_result->n_rows() ;
std::cout << "Rows: " << nRows << std::endl;
<br />
for ( idx=0 ; idx < n_fields; ++idx)<br />
{<br />
sql_field_c sql_field = sql_result->fetch_field( idx );<br />
printf( "[%s]\t", sql_field.get_name() );<br />
}<br />
printf("\n");<br />
<br />
for(__int64 i = 0; i<nRows ;++i)<br />
{<br />
sql_row_c row = sql_result->fetch_row();<br />
for(idx=0; idx < n_fields; ++idx)<br />
{<br />
printf( "%s\t", row[idx]);<br />
}<br />
printf("\n");<br />
}<br />
}<br />
|
|
|
|
|
I tried to use this class with mysql 5.0 but it don't work
Can anybody help me !!
Thanks!!!!
|
|
|
|
|
Actually, I been using it for a while with 5.0 and it works great.
Make sure you change the path in the project settings for the lib and include files. Also, make sure you update all the Lib files if you copy them to you local project dir.
|
|
|
|
|
Rolando
|
|
|
|
|
If you got compile errors like:
mysqlplus.obj : error LNK2001: unresolved external symbol _mysql_close@4
mysqlplus.obj : error LNK2001: unresolved external symbol _mysql_select_db@8
mysqlplus.obj : error LNK2001: unresolved external symbol _mysql_connect@16
mysqlplus.obj : error LNK2001: unresolved external symbol _mysql_init@4
mysqlplus.obj : error LNK2001: unresolved external symbol _mysql_free_result@4
mysqlplus.obj : error LNK2001: unresolved external symbol _mysql_query@8
mysqlplus.obj : error LNK2001: unresolved external symbol _mysql_store_result@4
mysqlplus.obj : error LNK2001: unresolved external symbol _mysql_insert_id@4
mysqlplus.obj : error LNK2001: unresolved external symbol _mysql_fetch_field@4
mysqlplus.obj : error LNK2001: unresolved external symbol _mysql_ping@4
mysqlplus.obj : error LNK2001: unresolved external symbol _mysql_num_rows@4
mysqlplus.obj : error LNK2001: unresolved external symbol _mysql_fetch_row@4
mysqlplus.obj : error LNK2001: unresolved external symbol _mysql_num_fields@4
mysqlplus.obj : error LNK2001: unresolved external symbol _mysql_fetch_field_direct@8
Then here is the solution: press alt+f7, goto the link tab and add this: "libmysql.lib " (without the "") in the Object/Library Modules
Where to put the files !!!!....
Cant you write a REALLY newbie toturial....
In your VC98/ folder
I am getting the following error using VC++6. I am just learning VC++/MySQL so it may be a "pilot error"
Compiling...
mysqlplus.cpp
C:\MySQL C++ Wrapper\mysqlplus.cpp(117) : error C2065: 'mysql_connect' : undeclared identifier
Error executing cl.exe.
mysqlplus.exe - 1 error(s), 0 warning(s)
Thank You in Advance
Just add the libraries to you c++ folder, dont use the new ones use these:
http://tangentsoft.net/mysql++/releases/mysql++-1.7.1-win32-vc++.zip
Hi ,
please help me, how can i fix this ?!
c:\documents and settings\ka$h\desktop\study\mysqlwrap_src\mysqlplus.cpp(397) : error C4716: 'sql_var_c::operator=' : must return a value
c:\documents and settings\ka$h\desktop\study\mysqlwrap_src\mysqlplus.cpp(406) : error C4716: 'sql_var_c::operator=' : must return a value
c:\documents and settings\ka$h\desktop\study\mysqlwrap_src\mysqlplus.cpp(415) : error C4716: 'sql_var_c::operator=' : must return a value
c:\documents and settings\ka$h\desktop\study\mysqlwrap_src\mysqlplus.cpp(421) : error C4716: 'sql_var_c::operator=' : must return a value
Someone already faced this problem
Return a value in the sql_vac_c::operator: like on the end:
return 0; //(if you dont want it to loop, but im not really 100% sure about this)
~NightGhost
|
|
|
|
|
I'm new to VC++ environment. I have installed Mysql server version 4.1 in my machine. I tried to compile and run your example program. When I compile the VC++ compiler shows the following linker error , even though I have included the "Mysql include folder" in include section and "Mysql lib (mysqlclient.lib)" in library section.
Linking...
ex01.obj : error LNK2001: unresolved external symbol "public: char * __thiscall sql_field_c::get_name(void)" (?get_name@sql_field_c@@QAEPADXZ)
ex01.obj : error LNK2001: unresolved external symbol "public: class sql_field_c __thiscall sql_result_c::fetch_field(unsigned int)" (?fetch_field@sql_result_c@@QAE?AVsql_field_c@@I@Z)
ex01.obj : error LNK2001: unresolved external symbol "public: unsigned int __thiscall sql_result_c::n_fields(void)" (?n_fields@sql_result_c@@QAEIXZ)
ex01.obj : error LNK2001: unresolved external symbol "public: class sql_result_c * __thiscall sql_query_c::store(void)" (?store@sql_query_c@@QAEPAVsql_result_c@@XZ)
ex01.obj : error LNK2001: unresolved external symbol "public: __thiscall sql_connection_c::~sql_connection_c(void)" (??1sql_connection_c@@QAE@XZ)
ex01.obj : error LNK2001: unresolved external symbol "public: __thiscall sql_query_c::~sql_query_c(void)" (??1sql_query_c@@QAE@XZ)
ex01.obj : error LNK2001: unresolved external symbol "public: int __thiscall sql_query_c::execute(char *)" (?execute@sql_query_c@@QAEHPAD@Z)
ex01.obj : error LNK2001: unresolved external symbol "public: __thiscall sql_query_c::sql_query_c(class sql_connection_c *)" (??0sql_query_c@@QAE@PAVsql_connection_c@@@Z)
ex01.obj : error LNK2001: unresolved external symbol "public: __thiscall sql_connection_c::sql_connection_c(char *,char *,char *,char *)" (??0sql_connection_c@@QAE@PAD000@Z)
LIBCMTD.lib(wincrt0.obj) : error LNK2001: unresolved external symbol _WinMain@16
Debug/MysqlTest.exe : fatal error LNK1120: 10 unresolved externals
Error executing link.exe.
Can you please give me the solution for this problem.
AT Karthikeyan
|
|
|
|
|
you need to link libmysql.lib
|
|
|
|
|
Hi all,
I'm looking for a way to execute simple queries (BCB6.0 <-> MySQL 4.1.18) and this wrapper looks great. I'm having problems getting things to work properly, though.
(Unresolved external 'mysql_close' / 'mysql_init' / 'mysql_real_connect' ...)
Is anyone here using Borland and the C++ Wrapper?
PLEASE contact me at magnus.winsth@bredband.net, ICQ 12715455 or at this forum of course.
All I want is to get a very very simple example to work...
A bunch of thanx in advance!!
/ Magnus Winsth
-----------------------------------------------
Fly safe and keep the dirty side down!
|
|
|
|
|
Where to put the files !!!!....
Cant you write a REALLY newbie toturial....
|
|
|
|
|
I am getting the following error using VC++6. I am just learning VC++/MySQL so it may be a "pilot error"
Compiling...
mysqlplus.cpp
C:\MySQL C++ Wrapper\mysqlplus.cpp(117) : error C2065: 'mysql_connect' : undeclared identifier
Error executing cl.exe.
mysqlplus.exe - 1 error(s), 0 warning(s)
Thank You in Advance
alan
|
|
|
|
|
I've got the same error. Please, could anyone help us with this error
|
|
|
|
|
please use mysql_real_connect instead of mysql_connecgt
|
|
|
|
|
Just replace 'mysql_connect' with 'mysql_real_connect()' with proper parameters.
|
|
|
|
|
How do you use this class to add binary data?
I find this class quite good - although I agree explanation is a bit short. However better this than nothing.
|
|
|
|
|
i changed the mysql_connect to mysql_real_connect and copyied the libmysql.dll to the same folder and also libmysql.lib to the project settings.
i have a mysql 4.1.18 server running, using headers/librarys from mysql++ 1.7.1 and using vc++6
below is my code, but i get "oops... didn't execute!!" as an output to the screen everytime. the login details and database name are correct. is it that my server isnt compatible with this or ??????
sql_connection_c connection( "test1", "localhost", "root", "abc");
sql_query_c query( &connection );
sql_result_c *sql_result = 0;
if ( !query.execute( "select * from login" ) )
{
printf( "oops... didn't execute!!\n" );
return;
}
|
|
|
|
|
Hi ,
please help me, how can i fix this ?!
c:\documents and settings\ka$h\desktop\study\mysqlwrap_src\mysqlplus.cpp(397) : error C4716: 'sql_var_c::operator=' : must return a value
c:\documents and settings\ka$h\desktop\study\mysqlwrap_src\mysqlplus.cpp(406) : error C4716: 'sql_var_c::operator=' : must return a value
c:\documents and settings\ka$h\desktop\study\mysqlwrap_src\mysqlplus.cpp(415) : error C4716: 'sql_var_c::operator=' : must return a value
c:\documents and settings\ka$h\desktop\study\mysqlwrap_src\mysqlplus.cpp(421) : error C4716: 'sql_var_c::operator=' : must return a value
Someone already faced this problem
|
|
|
|
|
Ok now i fixed that , now its giving all wierd linking errors
mysqlplus.obj : error LNK2019: unresolved external symbol _mysql_query@8 referenced in function "public: int __thiscall sql_query_c::try_execute(char *)" (?try_execute@sql_query_c@@QAEHPAD@Z)
mysqlplus.obj : error LNK2019: unresolved external symbol _mysql_store_result@4 referenced in function "public: int __thiscall sql_query_c::execute(char *)" (?execute@sql_query_c@@QAEHPAD@Z)
mysqlplus.obj : error LNK2019: unresolved external symbol _mysql_insert_id@4 referenced in function "public: __int64 __thiscall sql_query_c::insert_id(void)" (?insert_id@sql_query_c@@QAE_JXZ)
mysqlplus.obj : error LNK2019: unresolved external symbol _mysql_fetch_field@4 referenced in function "public: struct st_mysql_field * __thiscall sql_query_c::fetch_field(void)" (?fetch_field@sql_query_c@@QAEPAUst_mysql_field@@XZ)
mysqlplus.obj : error LNK2019: unresolved external symbol _mysql_ping@4 referenced in function "public: int __thiscall sql_query_c::ping(void)" (?ping@sql_query_c@@QAEHXZ)
mysqlplus.obj : error LNK2019: unresolved external symbol _mysql_num_rows@4 referenced in function "public: __int64 __thiscall sql_result_c::n_rows(void)" (?n_rows@sql_result_c@@QAE_JXZ)
mysqlplus.obj : error LNK2019: unresolved external symbol _mysql_fetch_row@4 referenced in function "public: class sql_row_c __thiscall sql_result_c::fetch_row(void)" (?fetch_row@sql_result_c@@QAE?AVsql_row_c@@XZ)
|
|
|
|
|
ft
u must link to libmysql.lib
then
see compiling on newer MySQL 4.1.x
it's all!
|
|
|
|
|
Hi,
I had a problem compiling this on MySQL 4.1.7.
Defining USE_OLD_FUNCTIONS will overcome the compile issues, but it still has linking problems [mysql_connect]
FYI, for anybody having this problem, changing the old mysql_connect to the new mysql_real_connect will solve this problem.
Change line in OPENDB *sql_connection_c::grabdb()
[line 117] if ( !mysql_connect( &odb->mysql, host, user, password ) )
To
if ( !mysql_real_connect( &odb->mysql, host, user, password, database, 0, NULL, 0 ) )
This should work fine [works for me!]
HTH
Mark
Windows, Linux and Internet Development Consultant
http://www.scriptsmiths.co.za
|
|
|
|