using c to access MySql database in Linux

nirmal

Member
Join Date
Jan 2003
Posts
17
Hi

This is a conveyor belt , barcode project. We use a slc 505, linux box, MySql and C/C++. I have scanners at specified points in the conveyor. When a box passes thru it, the scanner sends a message to the pc. This goes thru an ethernet port and has to be read using c to a MySql database to store the barcodes. Based on whether the previous box has exited the system, the pc has to send a signal to the plc which has to control the conveyor and the divertor to exit the box out of the system.
I would like to know if it is ok to use C or if there is any other free tool which can read the data in the sockets and store it in the MySql server. Also if any links about this with examples can be provided it will be very helpful.
Thanks a lot
nirmal
 
Nimral,

Yes you can write a peace of software in C/C++ to read data in the socket. I've done that under Windows but not under Unix OS. I'll try to get you the source code if you want to.

No need for any tool. You can do that yourself and it might take you 2 days if you're new in network programming.

BTW, it's a total of maximum 10 lines in C# or VB.NET.
 
Hi Naserals
I would very much like to have the source code. i will try some way of using it in linux. By the way if u can share the experiences u had with this project like the problems u faced, it will be very helpful for me.Iam a total novice to network programming in c. if u can comment the source code well,that will help me a lot.
Thank u
Nirmal
 
I think for the most part you can try a php connection I found that php and C are almost the same.



$dbh=mysql_connect ("localhost", "database_name", "PASSWORD HERE") or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ("database_name");


 
Ah Here comes chakorules
man.u have tried to help me out in every problem i have faced. Really appreciate ur good heart.u sure are into PLC.Thanks a lot.
 

Similar Topics

Hi All, Can anyone advise me on how to determine the AN of a genie instance I writing to. I have created a genie to display a valve and some text...
Replies
0
Views
81
I know this can be done, but I can't get the router config right. My goal is to physically connect(using an ethernet cable) a device(PLC, RTU...
Replies
9
Views
975
Hi guys, I want to get data from Microsoft access database using vijeo citect cicode editor.. however, I don't understand what the coding in...
Replies
0
Views
2,575
Hello! I am working on a Controllogix project with redundant PLCs. The primary and secondary racks both contain: [0]L71 [1]EN2T [2]CN2R [3]CN2R...
Replies
1
Views
1,811
Hi I am new to Omron PLC. I am using CJ2M-CPU33 PLC with a CF card. Communication is via ethernet with IP address 192.168.250.2 (PLC). When I...
Replies
2
Views
3,237
Back
Top Bottom