dcsimg
Results 1 to 2 of 2

Thread: Impasse in project and Porting VB.net to python

  1. #1

    Thread Starter
    New Member
    Join Date
    May 2020
    Posts
    9

    Impasse in project and Porting VB.net to python

    Hello all, hopefully I'm posting in the right place. I'm working on a project that allows customers to scan a bar code with a scan gun, they click upload and it sends the code to a mysql database where it can be viewed and sorted. We were planning on using a Raspberry Pi 4 with Raspbian and use Mono to run the .exe file. That turned out to be a dead end. We still want to use the Raspberry Pi so we've opted to attempt in eliminating windows from the equation. The easiest for us would be moving to Python. I am a very new programmer, so constructive criticism is welcomed. Finally, my question is: Can anyone help me brainstorm/give me ideas and guidance on how this code should look in Python?

    Thank you so much for your time and assistance!

    (Again, I'm a new programmer, I realize there are better alternatives to most of my code, which is why I'm here. Thank you!)

    Code:
    Imports MySql.Data.MySqlClient
    Public Class Form1
    
        Dim Uname As String
        ReadOnly connection As New MySqlConnection("datasource=192.168.1.134;port=3306;username='root';password='Khajiit19!';database = Barcodes")
    
        Private Sub Label1_Click(sender As Object, e As EventArgs)
    
        End Sub
    
        Private Sub TextBox1_TextChanged(sender As Object, e As EventArgs) Handles TextBoxPassword.TextChanged, TextBoxUsername.TextChanged
    
        End Sub
    
        Private Sub CheckBoxSP_CheckedChanged(sender As Object, e As EventArgs) Handles CheckBoxSP.CheckedChanged
    
            If TextBoxPassword.UseSystemPasswordChar = True Then
    
                TextBoxPassword.UseSystemPasswordChar = False
    
            Else
    
                TextBoxPassword.UseSystemPasswordChar = True
    
            End If
    
    
        End Sub
    
        Private Sub ButtonCancel_Click(sender As Object, e As EventArgs) Handles ButtonCancel.Click
    
            Me.Close()
    
        End Sub
    
        Private Sub ButtonLogin_Click(sender As Object, e As EventArgs) Handles ButtonLogin.Click
    
            Dim command As New MySqlCommand("SELECT `username`, 'password' FROM `Accounts` WHERE `username` = @username AND `password` = @password;", connection)
    
            command.Parameters.Add("@username", MySqlDbType.VarChar).Value = TextBoxUsername.Text
            command.Parameters.Add("@password", MySqlDbType.VarChar).Value = TextBoxPassword.Text
    
            Dim adapter As New MySqlDataAdapter(command)
            Dim table As New DataTable()
    
            Try
                adapter.Fill(table)
            Catch ex As Exception
                MessageBox.Show("Could Not Connect To MySQL Server")
            End Try
    
            If table.Rows.Count = 0 Then
                MessageBox.Show("Invalid username or password")
            ElseIf MessageBox.Show("Login Succesful") Then
                Dim Barcode = New Barcode()
                Me.Hide()
                Barcode.ShowDialog()
                Me.Close()
            End If
    
    
        End Sub
    End Class

  2. #2
    Lively Member Delaney's Avatar
    Join Date
    Nov 2019
    Location
    Paris, France
    Posts
    108

    Re: Impasse in project and Porting VB.net to python

    Hello,

    There exist a few converters (here and here) but I don't know if they are reliable. Do you know python language ?

    As you use mysql, I'd say the first would be to have a look to how to use it with python and then try to find some tutorial, code example in python to use a bar code scan system.

    Maybe you could try to post it on a python forum or on stack overflow python forum

    regards
    Last edited by Delaney; May 19th, 2020 at 04:42 AM.
    The best friend of any programmer is a search engine

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width