The following functions must be implemented:
The gateway sends data to the PC through the serial port. The PC collects data and parses the data and saves it to MySQL. Then, the JSP page reads and displays the data in MySQL.
Therefore, using C # To connect to MySQL DATA becomes a necessary process, which is described in detail here.
1. Download the desired file mysqldrivercs, for: http://sourceforge.net/projects/mysqldrivercs
2, Installation File: MySQLDriverCS-n-EasyQueryTools-4.0.1-DotNet2.0.exe, In the installation process may prompt an error, prohibit writing a DLL file, you can directly ignore it.
3. Add the mysqldriver. dll file under the installation file to the reference of the C # project.
4. Write the public processing class as follows:
(1) first, you must reference the namespace:
Using mysqldrivercs; <br/> using system. Data; <br/> using system. Data. ODBC;
(2) Write Public processing class
Public class sqlhelper <br/>{< br/> mysqlconnection conn = NULL; <br/> mysqlcommand commn = NULL; </P> <p> Public mysqlconnection getconnect () <br/> {<br/> conn = new mysqlconnection (New mysqlconnectionstring ("localhost", "wWater", "root", "123 "). asstring); <br/> return conn; <br/>}</P> <p> Public int runmysql (string SQL) <br/>{< br/> int COUNT = 0; <br/> try <br/>{< br/> conn = getconnect (); <br/> Conn. open (); <br/> commn = new mysqlcommand (SQL, Conn); <br/> COUNT = commn. executenonquery (); <br/> return count; <br/>}< br/> catch (exception ex) <br/>{< br/> throw; <br/>}< br/> finally <br/> {<br/> Conn. close (); <br/>}</P> <p>}
(3) reference the runmysql method in the actual process to insert data.