vendredi 17 novembre 2017

VB.net to SQL IF ELSE

Beginner Here,

need help with my program,

Table: Customer(CID,LOAD)

Imports System.Data.SqlClient

Dim con As New SqlConnection("server = JAYRJAYR\SQLEXPRESS; database = BabyThesis; integrated security = true")
Dim cmd As New SqlCommand

Private Sub TextBox1_TextChanged(sender As Object, e As EventArgs) Handles TextBox1.TextChanged

  If "LOAD" < 100 Then

        Label3.Visible = True

    Else

        If TextBox1.TextLength >= 3 Then

                cmd.CommandType = System.Data.CommandType.Text
                cmd.CommandText = "UPDATE Customer set LOAD =LOAD-100 WHERE CID = " & TextBox1.Text & " "
                cmd.Connection = con
                con.Open()
                cmd.ExecuteNonQuery()
                con.Close()

                Label2.Visible = True

                TextBox1.Clear()

            End If
        End If
End Sub

process of my program:

when i write the CID, it will detect if my LOAD is above 100 and below 100,

if Load is below 100, label 3 will show,

if Load is above 100, label 2 will show,

my CID should be 3 digits so i put "If TextBox1.TextLength >= 3 Then"

how to fix the LOAD thing?

how my program will detect LOAD ?

Thanks,

Aucun commentaire:

Enregistrer un commentaire