Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - MEDALI1TN

Pages: [1]
1
Open Discussion / write to a database from datagridview
« on: June 17, 2022, 01:35:23 PM »
I want to convert data from Firebird database to Mysql database, so i managed to put the data in the datagridview and after that i managed also to write those data in the Mysql database.
until now everything seems perfect.
I wanted to write in the database only new records.

Code: [Select]
Imports System.Configuration
Imports MySql.Data
Imports MySql.Data.MySqlClient
Imports System.Data.DataTable
Imports System.Data.SqlClient
Imports System.Data.Odbc
Imports System.Data
Imports System.Data.Odbc.OdbcCommand
Imports System.Data.OleDb

Public Class MainForm
    Public conn_odbc As OdbcConnection
    Public conn1 As OdbcConnection
    Public conn2 As OdbcConnection
    Public ConnMysql_protocol As MySqlConnection

Public Sub connection_to_firebird_prod()
        Dim str_odbc_prod As String
        str_odbc_prod = "DRIVER=Firebird/InterBase(r) driver;UID=****;PWD=****;DBNAME=*****.GDB;"
        conn1 = New OdbcConnection(str_odbc_prod)
    End Sub

Public Sub production()
        Dim str_odbc_prod As String
        str_odbc_prod = "DRIVER=Firebird/InterBase(r) driver;UID=****;PWD=****;DBNAME=****.GDB;"
        Dim odbc_connection_prod As New OdbcConnection(str_odbc_prod)
        Dim odbc_adapter_prod As New OdbcDataAdapter("select ID,NR,HR from FrirebirdTable", odbc_connection_prod)
        Dim table_odbc_prod As New DataTable
        odbc_adapter_prod.Fill(table_odbc_prod)
        DataGridView_production.DataSource = table_odbc_prod
        odbc_adapter_prod.Dispose()
        Dim mysql_connection_prod As New MySqlConnection("server=localhost;user id=****;database=mysqldatabase")
        Dim insert_in_mysql_prod As New MySqlCommand("INSERT INTO `mysqltable` (`ID`, `NR`, `HR`) VALUES (@ID,@NR,@HR)", mysql_connection_prod)
        Try
            mysql_connection_prod.Open()
        Catch exError As MySqlException
        End Try
        For i As Integer = 0 To DataGridView_production.RowCount - 1 Step +1
            insert_in_mysql_prod.Parameters.Add("@ID", MySqlDbType.Int64).Value = DataGridView_production.Rows(i).Cells(0).Value.ToString
            insert_in_mysql_prod.Parameters.Add("@NR", MySqlDbType.Int64).Value = DataGridView_production.Rows(i).Cells(1).Value.ToString
            insert_in_mysql_prod.Parameters.Add("@HR", MySqlDbType.Int64).Value = DataGridView_production.Rows(i).Cells(2).Value.ToString
           
            insert_in_mysql_prod.ExecuteNonQuery()
        Next
        mysql_connection_prod.Close()

    End Sub

End Class


2
Open Discussion / datagridview : auto update
« on: April 29, 2020, 09:51:36 AM »
How can I make auto update of the datagridview in vb.net.

3
Open Discussion / using a temporary table
« on: February 16, 2019, 03:48:04 PM »
Dear All,
In my code, I read an "X" variable that exists in a temporary table in another application (which I read this variable through the OPC server).

I want to keep this variable "X" in another temporary table in my code even after the disappearance of the table of the other application.

whenever the variable "X" changes in the temporary table of the other application, I must create a new column in my temporary table and save it in it.

Thx

4
Open Discussion / using class with AdvancedHMI
« on: December 24, 2018, 03:03:23 PM »
Dear all,
please i need to use a class in my program.
 
This one example that working good for me but without class (all in the main form):

Public Sub MainForm_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
        OpcDaCom1.Subscribe("adress_of_opc", 1, 0, AddressOf test)
    End Sub

Public Sub test(sender As Object, e As MfgControl.AdvancedHMI.Drivers.Common.PlcComEventArgs)
        variable = e.Values(0)
    End Sub


But i need to add the "public sub test" in another class and i will call it in the main form.

Thx

5
Hello All,
I need to count the number of hours of operation of a machine.
I have a bit (0: off; 1: on), when this bit is set to 1: the counter starts counting and when this bit is set to 0: the counter is paused.
and it waits for the bit set to 1 to start counting again.
if it is possible to have two counters, one can do resert and the other without reset.

6
Support Questions / Array value
« on: June 10, 2018, 04:39:19 AM »
Hello.
i'm new with AdvancedHMI. (i use the version 35)
i'm using an OPC server (KEPServerEx V4.5) in order to connect to PLC siemens s7 300. : connection ok.
the configuration of OpcDaCom1 inside AdvancedHMI : ok.
i use the AnalogValueDisplay to read a word value from the OPC : ok. (without code, just i put the correct TAG in the PLCaddressvalue).

the problem is :
i have one Foat Array tab [76 elements], and i need to read each value separate.
the best solution for me is to write them in a database.

thank you.

Pages: [1]