Hi ppl

  • Thread starter Thread starter Nakutenga
  • Start date Start date
N

Nakutenga

Guest
Hi ppl. Im using sql server database and vb net.I have the below pasted code that is supposed to save changes that I have made to a table in the database. I have two user interfaces one for adding new records and anotther one for Viewing all the records that exists in that table using a datagrid view. What the code does so far is to save the changes and yes the changes do appear at the datagridview. the problem is that, when I close the 2008 VS or switch from run mode to design mode and try to run the app again I find the data hasnt been saved it is lost.I have done data bindings for all the controls I dont know where the problem is. Kindly help.

Private Sub aveRecord_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles aveRecord.Click
If TxtAdminID.Text <> "" Or TxtBox.Text <> "" Or TxtFirstName.Text <> "" Or TxtLastName.Text <> "" Or TxtCity.Text <> "" Or TxtEmailAddress.Text <> "" Or TxtMobileNo.Text <> "" Or TxtUserName.Text <> "" Or TxtMobileNO2.Text <> "" Or txtPassword.Text <> "" Then
cn.Open()
cmd.CommandText = "INSERT INTO AdminRegistrationTable(AdminID,PostOfficeNo,FirstName,LastName,City,EmailAddress,PrimaryMobilePhone,UserName,AlternativeMobilePhone,Pasword) VALUES (" & TxtAdminID.Text & ", " & TxtBox.Text & "," & TxtFirstName.Text & " ," & TxtLastName.Text & ", " & TxtCity.Text & ", " & TxtEmailAddress.Text & " , " & TxtMobileNo.Text & " , " & TxtUserName.Text & " , " & TxtMobileNO2.Text & ", " & txtPassword.Text & ")"
cmd.CommandType = CommandType.Text
cmd.Connection = cn
cmd.ExecuteNonQuery()

cn.Close()
TxtAdminID.Text = ""
TxtBox.Text = ""
TxtFirstName.Text = ""
TxtLastName.Text = ""
TxtCity.Text = ""
TxtEmailAddress.Text = ""
TxtMobileNo.Text = ""
TxtUserName.Text = ""
TxtMobileNO2.Text = ""
txtPassword.Text = ""
MsgBox("RECORD SAVED SUCCESSFULLY!!!", MsgBoxStyle.MsgBoxRight, "SAVE")
End If
End Sub

Continue reading...
 
Back
Top