Click here to Skip to main content
15,886,578 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Public Class Employee

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim con As SqlConnection = New SqlConnection("Data Source=S-MHAMEED\SQL2008RTWO;Initial Catalog=comp.task;User ID=sa;Password=likebefore")
        If TextBox1.Text = String.Empty Then
            MessageBox.Show("Please Insert Emb Number !  ")
        End If
        If ComboBox1.Text = String.Empty Then
            MessageBox.Show(" Please Insert Section ! ")
            If TextBox3.Text = String.Empty Then
                MessageBox.Show("Please Insert Emp Name ! ")
            End If
            If TextBox5.Text = String.Empty Then
                MessageBox.Show("Insert Job Description ! ")
            End If
            If TextBox6.Text = String.Empty Then
                MessageBox.Show("Insert Section Name !  ")
            End If
            If TextBox8.Text = String.Empty Then
                MessageBox.Show("Insert Basic Salary ! ")
            End If


        Else
            Using con
                con.Open()
                Dim sqlcomm As New SqlCommand()
                sqlcomm.Connection = con
                sqlcomm.CommandText = "insert_emp"
                sqlcomm.CommandType = CommandType.StoredProcedure
                sqlcomm.Parameters.AddWithValue("@emp_num", Convert.ToInt32(TextBox1.Text))
                sqlcomm.Parameters.AddWithValue("@debt_num", Convert.ToInt32(ComboBox1.Text))
                sqlcomm.Parameters.AddWithValue("@emp_name", TextBox3.Text)
                sqlcomm.Parameters.AddWithValue("@emp_p_date", DateTimePicker2.Text())
                sqlcomm.Parameters.AddWithValue("@emp_work_date", DateTimePicker1.Text())
                sqlcomm.Parameters.AddWithValue("@emp_sal", Convert.ToInt32(TextBox8.Text))
                sqlcomm.Parameters.AddWithValue("@emp_desc", TextBox5.Text)
                sqlcomm.Parameters.AddWithValue("debt_name", TextBox6.Text)
                Dim queryResult As Integer
                Dim cmd As New SqlCommand
                If queryResult > 0 Then
                    cmd.CommandText = "insert into emb_num (Dt,ID)VALUES ('" & TextBox1.Text & "' , '" & TextBox1.Text & "')"
                    queryResult = cmd.ExecuteScalar()
                    MsgBox("Added Successfuly")
                Else

                    'MessageBox.Show("Already Exists!", "ALI ENTERPRISES", MessageBoxButtons.OK, MessageBoxIcon.Information)

                End If

                sqlcomm.ExecuteNonQuery()
                ' con.Open()

                MessageBox.Show("Add Sucssfully  ")
                'TextBox1.Text = ""
                ComboBox1.Text = ""
                TextBox3.Text = ""
                TextBox5.Text = ""
                TextBox6.Text = ""
                TextBox8.Text = ""
                'Form1_Load3()
                con.Close()
            End Using
        End If
    End Sub


What I have tried:

transform tap key with enter key in vb.net
Posted
Updated 11-Feb-18 5:18am
Comments
OriginalGriff 11-Feb-18 10:50am    
This is not a good question - we cannot work out from that little what you are trying to do.
Remember that we can't see your screen, access your HDD, or read your mind - we only get exactly what you type to work with. And I have no idea what you are trying to do - please try explaining in rather more words!
Use the "Improve question" widget to edit your question and provide better information.

1 solution

Maybe that is what you are looking for:
c# - How to make Enter on a TextBox act as TAB button - Stack Overflow[^]
It's for C#, but C# and VB.NET manipulate the same .NET objects under the hood, so you will get an idea.
 
Share this answer
 

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