i have get the following code from a tutorial and compiled by a Borland c++ version 5.02 compiler .
but it give the error of unable to open the file 'BIDSDT.LIB'
and the code is as following
#include <iostream.h>
#include <winsock2.h>
#include <mysql.h>
int connections();
//using namespace std;
MYSQL *connection, mysql;
MYSQL_RES *result;
MYSQL_ROW row;
int query_state;
int main() {
connections();
return 0;
}
int connections()
{ mysql_init(&mysql);
//connection = mysql_real_connect(&mysql,"host","user","password","database",0,0,0);
connection = mysql_real_connect(&mysql,"localhost","root","123","test",0,0,0);
if (connection == NULL) {
cout << mysql_error(&mysql) << endl;}
return 1;
}
Please suggest there is any issue to compiler or Code or my method of compiling
11 replies to this topic
#1
Posted 15 April 2010 - 09:50 PM
|
|
|
#2
Posted 16 April 2010 - 08:01 AM
What compiler did the tutorial recommend you use? Borland C++ 5.02 is VERY old.
#3
Posted 16 April 2010 - 08:50 PM
Thanks for to intrust !
In the tutorial author used Dev c++ compiler .But i think it is not a matter of compiler .
I had used Dev C++ also but it give building error 255
i have properly linked the required libraries.During compilation it gives no error no warning but as it going to build or make the project it gives the error ....
Please help ...
In the tutorial author used Dev c++ compiler .But i think it is not a matter of compiler .
I had used Dev C++ also but it give building error 255
i have properly linked the required libraries.During compilation it gives no error no warning but as it going to build or make the project it gives the error ....
Please help ...
#4
Posted 17 April 2010 - 08:47 PM
First of all get a decent compiler such as Code::Blocks with MinGW compiler or VC++ 2010 express. Dev-C++ is a crapy IDE that has not been updated for several years now -- its dead and buried. Then download and install MySQL++, which is c++ wrapper for the functions in mysql.h. After that read and do the MySql++ tutorial that you will find on their web site.
And you can not use that 16-bit Borland compiler to access 32-bit database engines such as MySQL. Just will not work. So you can toss out that old crapy compiler too.
And you can not use that 16-bit Borland compiler to access 32-bit database engines such as MySQL. Just will not work. So you can toss out that old crapy compiler too.
Visit Grandpa's Forums, a social networking forum, with family-oriented arcade games, blogs, discussion forums, and photo albums.
#5
Posted 20 April 2010 - 07:57 AM
Can any one tell me know that how i can write a simple query to get data !
i have created database with name "test" and a table in it by name "table_t".............
i have created database with name "test" and a table in it by name "table_t".............
#6
Posted 20 April 2010 - 02:04 PM
You really need to read an SQL tutorial or book. A simple query might be SELECT * FROM table; That will return everything in the table named "table". Capitalization is not important, I like to put SQL keywords in upper case. If you want to limit the query to certain field values in the table then you add a WHERE CLAUSE. For example if your table contains a field named "name" and one or more rows contains Smith then you might code it like this: SELECT * from table WHERE name = "smith"; It can get quite a bit more complicated, such as selecting from multiple tables and using multiple tables in the WHERE clause (sometimes called joins).
A good SQL tutorial should teach you all this.
A good SQL tutorial should teach you all this.
Visit Grandpa's Forums, a social networking forum, with family-oriented arcade games, blogs, discussion forums, and photo albums.
#7
Posted 21 April 2010 - 09:40 AM
dear i have written the Mysql queries but how i can use local variables of a function in the queries !
plz tell me
plz tell me
#8
Posted 21 April 2010 - 10:12 AM
Just format the string. Here is an example in C code.
This is a c++ example:
I could be a little more specific if I knew what columns are in the table you want to query.
int n = 123;
char *tablename = "mytable";
char iobuf[255] = {0};
sprintf(iobuf, "SELECT * FROM %s WHERE data = %d", tablename, n);
This is a c++ example:
#include <string>
#include <sstream>
#include <iostream>
using namespace std;
using namespace std;
int main()
{
int n = 123;
string tablename = "mytable";
string name = "Tom Jones";
stringstream str;
str << "SELECT * FROM " << tablename << " WHERE field = " << n;
str << " AND name = '" << name << "'";
cout << str.str() << '\n';
}
I could be a little more specific if I knew what columns are in the table you want to query.
Visit Grandpa's Forums, a social networking forum, with family-oriented arcade games, blogs, discussion forums, and photo albums.
#9
Posted 21 April 2010 - 11:14 AM
i want to get input from the user by keyboard and serial port and then want to use it in queries .
So then how i will use string variable in the query function.
So then how i will use string variable in the query function.
#10
Posted 21 April 2010 - 09:23 PM
while(true)
{
read post #8 above.
}
Visit Grandpa's Forums, a social networking forum, with family-oriented arcade games, blogs, discussion forums, and photo albums.
#11
Posted 22 April 2010 - 06:31 AM
thanx dear now my next step is to get data from serial port of a PC !
So tell the functions..........................
So tell the functions..........................
Edited by great, 22 April 2010 - 07:18 AM.
#12
Posted 22 April 2010 - 05:05 PM
If you are using MS-Windows then use win32 api functions. Read all about MS-Windows communications resources here. You will find a few example C programs, like this one.
Visit Grandpa's Forums, a social networking forum, with family-oriented arcade games, blogs, discussion forums, and photo albums.
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users


Sign In
Create Account

Back to top









