Public Sub add_emp(ByVal emp As EmployeeObj)
Dim con As New SqlConnection
Dim sqlcmd As SqlCommand
'Dim sqlrdr As SqlDataReader
Try
If is_emp(emp.Id) = False Then
con.ConnectionString = My.Resources.ConnString
con.Open()
sqlcmd = New SqlCommand("INSERT INTO [Employees] (" _
& "[Id], [SocialSecurity], [FirstName], " _
& "[MiddleName], [LastName], [Suffix], " _
& "[Address], [City], [State], " _
& "[Zipcode], [AptNum], [Phone], [AltNumber], " _
& "[IdNum], [IdType], [IssuingState], [ExpDate], " _
& "[HireDate], [Rehire], [Comments], [SecLevel])" _
& "VALUES ( " _
& "'" & emp.Id & "', '" & emp.SSN & "', " _
& "'" & emp.fName & "', '" & emp.mName & "', " _
& "'" & emp.lName & "', '" & emp.suffix & "', " _
& "'" & emp.address & "', '" & emp.city & "', " _
& "'" & emp.state & "', '" & emp.zipcode & "', " _
& "'" & emp.aptNum & "', '" & emp.phoneNum & "', " _
& "'" & emp.atlNum & "', '" & emp.idNum & "', " _
& "'" & emp.idType & "', '" & emp.issuingState & "', " _
& "'" & emp.expDate & "', '" & emp.HireDate & "', " _
& "'" & emp.rehire.ToString & "', '" & emp.comments & "', " _
& emp.seclevel & ")", con)
'sqlcmd.ExecuteNonQuery()
Dim check As Integer = sqlcmd.ExecuteReader.RecordsAffected()
If check > 0 Then
MsgBox("Employee succesfully to added")
Else
MsgBox("Failure to add new Employee")
End If
sqlcmd.UpdatedRowSource = UpdateRowSource.Both
End If
Catch ex As Exception
MsgBox(ex.Message)
Finally
con.Close()
End Try
End Sub
While the debugger is open I can retrieve the data that I add using this sub but when i re run the debugger then all the data the was entered is gone. Any help would be much appriciated. Thank You.
-Everett