Click here to Skip to main content
15,914,225 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi, I tried a lot of things to do this but nothing its working

Ihave this code right now, how can I put that into the label?

VB
Dim LeitorSQL2 As MySqlDataReader
    Dim conn As New MySqlConnection
        conn.Open()
            Dim Query2 As String
            Query2 = "SELECT MAX(OcorrenciaID) + 1 as 'NovoID' FROM 8Gest.ocorrencias"
            Dim AutoNumero = New MySqlCommand(Query2)
            LeitorSQL2 = AutoNumero.ExecuteReader
            While LeitorSQL2.Read
                Dim autonmr = LeitorSQL.GetString("NovoID")
                lblNumeroAuto.Text = autonmr
            End While
            conn.Close()


What I have tried:

I already tried

VB
lblNumeroAuto.Text = (autonmr)
lblNumeroAuto.Text = 3 '(This didnt work too)
lblNumeroAuto.Text += autonmr
Posted
Updated 16-Apr-18 12:16pm
v3

Try:
lblNumeroAuto.Text += autonmr
 
Share this answer
 
Comments
Member 13780554 15-Apr-18 15:03pm    
Don't work :(
OriginalGriff 16-Apr-18 4:48am    
"Don't work" is probably the most useless problem report we get - and we get it a lot. It tells us nothing about what is happening, or when it happens.
So tell us what it is doing that you didn't expect, or not doing that you did.
Tell us what you did to get it to happen.
Tell us any error messages.
I found the error.. Is just the stupid thing ever.. I forgot to make the connection in
VB
Dim AutoNumero = New MySqlCommand(Query2)

The code work if I put
VB
Dim AutoNumero = New MySqlCommand(Query2, conn)
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900