» »

VB2010 - class

VB2010 - class

korenje3 ::

Zdravo. Imam še en problem. V klasi sqlhandle ne vem kako bi prenesel fmysqltest.sqladdress.text
načeloma dela, če uvozim iz instance.mysqlconfig.address

v trenutni situaciji mi zazna neskončni loop... prosim za rešitev.

prilagam del kode:

Imports System.Configuration
Imports System.Text.RegularExpressions
Imports MySql.Data.MySqlClient
Imports System.Threading
Imports System.ComponentModel

Public Class fmysql
    Dim instance As New mysection
    Dim test As New Process
    Dim worker As New workers
    Dim sqlhandle As New sqlhandle

    Private Sub fmysql_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        instance = instance.open
        sqladdress.Text = instance.mysqlconfig.address
        sqladdress2.Text = instance.mysqlconfig.address2
        sqlport.Text = instance.mysqlconfig.port
        sqlport2.Text = instance.mysqlconfig.port2
        sqlusername.Text = instance.mysqlconfig.username
        sqlpassword.Text = instance.mysqlconfig.password
        sqlpasswordr.Checked = instance.mysqlconfig.passwordr
        sqlautoconnectr.Checked = instance.mysqlconfig.autoconnect
    End Sub

    Private Sub save_button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles save_button.Click
        instance.mysqlconfig.address = Regex.Replace(sqladdress.Text, "[^0-9.:a-z]", "")
        instance.mysqlconfig.address2 = Regex.Replace(sqladdress2.Text, "[^0-9.:a-z]", "")
        instance.mysqlconfig.port = Regex.Replace(sqlport.Text, "[^0-9]", "")
        instance.mysqlconfig.port2 = Regex.Replace(sqlport2.Text, "[^0-9]", "")
        instance.mysqlconfig.username = sqlusername.Text
        instance.mysqlconfig.passwordr = sqlpasswordr.Checked
        If sqlpasswordr.Checked = True Then
            instance.mysqlconfig.password = sqlpassword.Text
        Else
            instance.mysqlconfig.password = Nothing
        End If
        instance.mysqlconfig.autoconnect = sqlautoconnectr.Checked

        instance.save()
        Me.Close()
    End Sub

    Private Sub cancel_button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cancel_button.Click
        Me.Close()
    End Sub

    Private Sub connect_button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles connect_button.Click
        If worker.isbusy = False Then
            worker.startasync()
        End If
    End Sub

    Private Sub disconnect_button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles disconnect_button.Click
        sqlhandle.close()
    End Sub

    Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
        If sqlhandle.state = ConnectionState.Open Then
            ToolStripStatusLabel1.Text = "Connected"
        Else
            ToolStripStatusLabel1.Text = "Not connected"
        End If
        If sqlhandle.state = ConnectionState.Connecting Then
            ToolStripProgressBar1.PerformStep()
        Else
            ToolStripProgressBar1.Value = 0
        End If
    End Sub

End Class

Class workers
    Private WithEvents backgroundWorker1 As New System.ComponentModel.BackgroundWorker
    Sub init()
        backgroundWorker1.WorkerReportsProgress = True
        backgroundWorker1.WorkerSupportsCancellation = True
    End Sub
    Function isbusy() As Boolean
        Return backgroundWorker1.IsBusy
    End Function
    Sub startasync()
        backgroundWorker1.RunWorkerAsync()
    End Sub
    Sub cancelasync()
        backgroundWorker1.CancelAsync()
    End Sub
    Sub dispose()
        backgroundWorker1.Dispose()
    End Sub
    Private Sub BackgroundWorker1_DoWork(ByVal sender As System.Object, ByVal e As System.ComponentModel.DoWorkEventArgs) Handles backgroundWorker1.DoWork
        Dim worker As BackgroundWorker = CType(sender, BackgroundWorker)
        Dim sqlhandle As New sqlhandle
        sqlhandle.open()
    End Sub
End Class


Class sqlhandle
    Dim sqlcon As New MySqlConnection

    ''' <summary>
    ''' kaj tukaj storiti?
    ''' </summary>
    ''' <remarks></remarks>
    Dim fmysqltest As New fmysql


    Public Sub open()
        MsgBox(fmysqltest.sqladdress.Text)

        If sqlcon.State <> ConnectionState.Closed Then
            MsgBox("Connection not closed. First close connection.")
            Exit Sub
        End If
        Try
            sqlcon.ConnectionString = "Database=trooptool;Data Source=" & fmysql.sqladdress.Text & ";User Id=" & fmysql.sqlusername.Text & ";Password=" & fmysql.sqlpassword.Text & ";port=" & fmysql.sqlport.Text & ";"
            sqlcon.Open()
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try
    End Sub
    Public Sub close()
        sqlcon.Close()
        sqlcon.Dispose()
    End Sub
    Public Function state()
        Return sqlcon.State
    End Function
End Class


Vredno ogleda ...

TemaSporočilaOglediZadnje sporočilo
TemaSporočilaOglediZadnje sporočilo
»

Odpiranje programa v Visual Studio

Oddelek: Programiranje
8911 (769) darkolord
»

vb.net: dynamic textbox

Oddelek: Programiranje
51180 (1070) saule
»

Visual Studio - koda za prikaz OS?

Oddelek: Programiranje
91082 (849) detroit
»

[VB] Komunikacija s serijskimi napravami

Oddelek: Programiranje
412306 (1580) mNeRo
»

VB.net MDI in formi splošno

Oddelek: Programiranje
91615 (1558) strel

Več podobnih tem