When textbox is null it will not insert data

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ayakamacy
    New Member
    • May 2015
    • 14

    When textbox is null it will not insert data

    Hello there, I have 2 tables in my database, all i want to do is when the time txtJobstart is null then it will not insert the data to the tbl2 but all the data from other fields will save to tbl1.

    Code:
    If txtJobStart.Text = "" Then
                'Don't save, do nothing
            Else
                Dim constr As String = ConStrX
                Using test As New SqlConnection(constr)
                    Using probe As New SqlCommand("JobStartMonitoring")
                        Using sda As New SqlDataAdapter()
                            probe.CommandType = CommandType.StoredProcedure
                            probe.Parameters.AddWithValue("@JobStart", txtJobStart.Text)
                            probe.Parameters.AddWithValue("@TotalNoOfPins", txtTotalPins.Text)
                            probe.Parameters.AddWithValue("@TotalNoOfJobs", txtTotalJO.Text)
                            probe.Connection = test
                            test.Open()
                            probe.ExecuteNonQuery()
                            test.Close()
                        End Using
                    End Using
                End Using
            End If
  • yarbrough40
    Contributor
    • Jun 2009
    • 320

    #2
    I'm sorry... is there a question here I'm missing?

    Comment

    Working...