Database Connection To SQL Database - CX-Supervisor Introduction Installation The following programs / drivers must be installed:. The SQL server mysql-3.23.5-win. 2. The ODBC driver for mysql MyODBC 3.5.03.exe. This is the draw dsn file and is very simple. 3. If no database exists then MySql-Front will be installed. In the program, the databases are created and tested. SQL Server If the SQL Server is already running then you can see a green traffic light, otherwise it must be started manually (C: \ mysql \ bin WinMysqladmin). The server can also be configured (user) in this program. Then start MySQL front and a new connection. For a local Database gives you Hostname = localhost, user = root port and 3306th The connection is via TCP / IP on the local host. The root user is a standard user without a password. To be users and get passwords you have to create and configure the dsn file with these specifications. my.ini File WinMysqladmin with the program will include an ini file (tab - Choose Save and modification). In this are the settings of the SQL Server and computer settings.network Both computers must be installed with MySQL. Configuration of the local SQL Server, see above. To get from one machine to the computer with the Database the hostname or IP address must be known. Furthermore you need the username and password of the data bank on which you want access (if it is not root). To connect to MySQL start up and go to Connect. In this window, you can set the parameters for the new connection A. Connection name, host / IP = IP address (eg 2.68.20.30) User = username or root, password = if needed and the database which one wants to read. After the entries has been made these are stored, and then connect to the server. Creating a dsn file The dsn file contains the connection data to the SQL database. Settings \ Administration \ ODBC sources, the database contains a dsn file allocated on which the data is realized. For the dsn file tab and select the ODBC driver (MYSqlODBC) and a file name. This applies only to the MySQL ODBC driver Version 3.5. With another driver, it is difficult to create a dsn file. Creating a database When starting MySqlFront must be connected with the SQL Server and the data base. If another user name other than "root" is given then use this, same applies for the password. If you have a successful connection - create the front end with MYSQL database. Table, fields and set the datatypes of the fields. Set the structure of the database. Generated by myomron - https://www.myomron.com/index.php?action=kb&article=205 of 0
CX-Supervisor Open the editor on the job (Workspace) tab and select Database add a link (right mouse button). Choose the dsn path (it is located C: \ Program Files \ Common Files \ ODBC \ Data Source). After the connection, you can assign variables to the record and the fields. Append records to enable a second row with the same structure to be created. Only the fields with the property ADD will get the variables assigned in the record to be written. To work properly, the database and dataset (recordset) must always be specified in SQL in the DB commands. Limitations The current record number read through Supervisor taken from the SQL database, is always higher than the actual data displayed. A better method is currentpage, which agrees with the database entries match. The same applies to 'next record' wherein the Next pointer jumps 2 rows further, not to NextPage or Previous, PreviousPage. Headings are not supported with the SQL database. To learn what functions of the database are used 'dbsupport'. The returned function is either supported or 0 is not supported. The Record function change does not alter the currently displayed but the next record. When you append data to the SQL database the sorting appears illogical. In my example were all appended records are 5sec the Counter indicates the current number. In the Access database they are all in ascending order, with the SQL records less than 700 descending order and then the rest in ascending order.cx-supervisor Settings The setting is analogous to an Access database, just select the dsn file that you previously created. Select the datasource and then for selecting the dsn file. You should be in the folder C: \ Program Files \ Common Files \ ODBC \ Data Sources \ stand. When compiling the file, you can specify this folder. After these settings, you can connect to the database (SQL server must be running). Command DBOpen( â ždb Name" ) DBClose( â ždb Name" ) DBProperty->BOF Not true if the database is in its early stages DBProperty->EOF Generated by myomron - https://www.myomron.com/index.php?action=kb&article=205 2 of 0
DBProperty->Current Record Always displays a set one more than actual data DBProperty->Record count DBProperty->Current page Gives the actual number of the displayed entry again DBProperty->Page count DBProperty->Page size? DBProperty->Field count Always shows 0 even though the database has 3 fields DBStatus->Open DBStatus->Close Always true even if the database is open DBMove->First DBMove->Last DBMove->Next 2 sets of jumps return value works correctly DBMove->NextPage Return value is 0 when the function was executed correctly DBMove->Previous No reaction DBMove->PreviousPage Also jumps to the next sequence, like Next and always returns 0 DBMove->Position Also jumps to the next sequence, like Next and always returns 0 DBRead DBDelete( â ždb Name" ) It will delete the current record displayed Generated by myomron - https://www.myomron.com/index.php?action=kb&article=205 3 of 0
DBWrite Has the same problem it will be the next row changed, not the displayed DBAddNew DBUpdate Only after a record added DBExecute->Requery DBExcute->SQL SQL commands can be sent to the database comandsql = "UPDATE Table SET Counter_ =" Value = ValueToText (Count SQL) comandsql + value = comandsql comandsql = comandsql + "WHERE position = 0" bresult = DBExecute ( "Connection_SQL_dsn", "SQL", comandsql) IF! bresult THEN Status_SQL = DBGetLastError ( "Connection_SQL_dsn", TRUE) ENDIF SQL command in Table in the column counter to change the value SET Supervisor into a point in the text and convert the command to add. SQL command to set the value in each row to 0, by the column heading is entered. SQL command to send to the database with the Execute method. If the return value = 0 then last query error. Generated by myomron - https://www.myomron.com/index.php?action=kb&article=205 4 of 0
Column indicates the facility from which the plant data comes. A record is always assigned to a facility. Enabled column 2 indicates whether the plant data exists and thus whether the data is current. Type E/A Type Array Size Plant_Active 0 Write into the DB cmdsql Text SQL command Data_Plant Data_Plant2 Data_Plant3 Generated by myomron - https://www.myomron.com/index.php?action=kb&article=205 5 of 0
Data_Plant4 DB_Plant DB_Plant_Active DB_Plant_Active DB_Plant_Active2 DB_Plant_Active3 DB_Plant_Active4 DB_Data_Plant DB_Data_Plant2 Generated by myomron - https://www.myomron.com/index.php?action=kb&article=205 6 of 0
DB_Data_Plant3 DB_Data_Plant4 DB_Data - to [0] DB_Data2 - to [0] DB_Data3 - to [0] DB_Data4 - to [0] DB_Data5 - to [0] DB_Data6 - to [0] Generated by myomron - https://www.myomron.com/index.php?action=kb&article=205 7 of 0
DB_Data7 - to [0] loop Loop counter Pointerpoint Text serror_db Text Error message svalue Text ValueToText data conversion Writing the Data into the SQL Database Reading the Data from a SQL Database REM Data Plant DBMove ( "DAS_DB_Plants.Table", "FirstPage") bresult = DBRead ( "DAS_DB_Plants.Table") IF! BResult THEN Generated by myomron - https://www.myomron.com/index.php?action=kb&article=205 8 of 0
Status_SQL = DBGetLastError ( "DAS_DB_Plants", TRUE) ENDIF DB_Plant_active = DB_Plant_active IF THEN DB_Plant_active FOR Loop = 0 to 6 IntTest = Loop + SValue = ValueToText (inttest) Points pointer = "DB_Data" + svalue DB_Data_Plant [Loop] = ^ pointer points NEXT ENDIF Reading queries from the SQL Database Within the Database tab, a table with SQL text appears, here you can create all the desired points to add.reading queries from the SQL Database Here are the points-based array points (eg SQL_Data) from the displayed query. This is accessed through the index. comandsql = "SELECT * FROM table WHERE " comandsql = comandsql + Query_Column + " = " texttest = ValueToText(Query_Value) comandsql = comandsql + texttest bresult = DBExecute( "DAS_DB_Plants.SQL_Text", "Source", comandsql ) IF!bResult THEN Status_SQL = DBGetLastError( "DAS_DB_PLants", TRUE ) Generated by myomron - https://www.myomron.com/index.php?action=kb&article=205 of 0
ENDIF DBExecute( "DAS_DB_Plants.SQL_Text", "Requery" ) DBRead( "DAS_DB_Plants.SQL_Text" ) Generated by myomron - https://www.myomron.com/index.php?action=kb&article=205 0 of 0