Good evening guys,

I'm having a problem on my web page. I'm trying to store a data on my mssql but it's not saving anymore. but it was working perfectly this morning. it doesn't display any error so i don't know what happened.

Thanks in advance.

Recommended Answers

All 9 Replies

if you havent changed any codes since the last time you used it, it may likely be a session error.

Is there a session that expires at any given time or even preventing you to store in mysql.

Are you able to retreive data? in other words, can you issue different SQL commands and get the same result or are some of the SQL commands not working while others are?

i was able to open the database but the code in the submit button where the inputted data will be stored on the mssql is not working.

can you post the code that stores data in the db?

 Dim cb As New SqlCommandBuilder(da)
        Dim dsNewRow As DataRow
        Dim genderStr As String
        '//ADDING DATA TO THE DATABASE
        Try
            If (inc <> 0) And maleRB.Checked = True Then
                genderStr = maleRB.Text
            ElseIf femaleRB.Checked = True Then
                genderStr = femaleRB.Text


                dsNewRow = ds.Tables("EnrollmentDB").NewRow()

                dsNewRow.Item("studentLvl") = studentLvlDDL.Text.Trim
                dsNewRow.Item("studentSection") = studentSectionTB.Text.Trim
                dsNewRow.Item("firstName") = firstNameTF.Text.Trim
                dsNewRow.Item("middleInitial") = miTF.Text.Trim
                dsNewRow.Item("lastName") = lastNameTF.Text.Trim
                dsNewRow.Item("gender") = genderStr
                dsNewRow.Item("personAge") = ageTB.Text.Trim
                dsNewRow.Item("birthDate") = monthDDL.Text & " " & dayDDL.Text & " " & yearDDL.Text
                dsNewRow.Item("civilStatus") = civilStatusDDL.Text.Trim
                dsNewRow.Item("homeAddress") = homeAddressTF.Text.Trim
                dsNewRow.Item("residenceNo") = telNoTF.Text.Trim
                dsNewRow.Item("cellNo") = cellNoTF.Text.Trim
                dsNewRow.Item("motherName") = motherNameTB.Text.Trim
                dsNewRow.Item("occupationMother") = motherOccupationTB.Text.Trim
                dsNewRow.Item("fatherName") = fatherNameTB.Text.Trim
                dsNewRow.Item("occupationFather") = fatherOccupationTB.Text.Trim
                dsNewRow.Item("emergencyPerson") = emergencyPersonTB.Text.Trim
                dsNewRow.Item("residenceTelEP") = emergencyPtelTB.Text.Trim
                dsNewRow.Item("cellNoEP") = emergencyPcel.Text.Trim
                dsNewRow.Item("TypeOfPayment") = topDDL.Text

                ds.Tables("EnrollmentDB").Rows.Add(dsNewRow)

                da.Update(ds, "EnrollmentDB")

                MsgBox("Successful registration.")

            Else
                MsgBox("registration failed.")
            End If
        Catch err As SqlException
            MsgBox(err.Message)
            ds.Tables("EnrollmentDB").RejectChanges()
        End Try

update

try using the return value of update to check if it returns 0 or 1?
something could be causing the dataAdapter to not update the table but yet not raise an exception out of it, which is currently your only error handling.

actually, are you trying to add a male and its not working?

because from the code you posted its like if you accidently merged 2 if statements that should not have been merged...
you have :

If male Then
    gender = male
ElseIf female Then
    gender = female

    update DB
    print Sucess

Else
    print Fail
End If

while you should have :

If male Then
    gender = male
ElseIf female Then
    gender = female
End If

Update DB

If Sucess Then
    print Sucess
Else
    print Fail
End If

Now i know where i got the error.. I have if structure before the code and somehow it prevents it from saving the data.

Thank you guys for your help that solved the problem sir philippe.

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.