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

Recommended Answers

All 4 Replies

Never mind folks figured it out the folder the database was set to read only.

Well I thought that was the case and maybe it still is ... does anyone know if the bin folder the debugger uses stays as read only because i've set it to be otherwise and it goes back to being read only. Again any help would be much appriciative.

Set Database file property from properties windows:

Copy To Output : Copy if newer

Thank you that seems to have worked didn't know anything about that property. I do appriciate the help.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.