Hi All,
I have made a form to process all the details of employees in the organisation, it has several fields, an edit and a save button. All fields are set as read only on the form load. When i click edit the fields become available for editing. When i click the save button i want it to update the tables in the database to the fields on the form. For some reason the update query does not run, there is no error it just doesn't update any data in the table. Any Ideas?
Do i need to use a dataset or is this fine?
Thanks in advance!Code:Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSave.Click Dim conn As SqlClient.SqlConnection conn = New SqlClient.SqlConnection conn.ConnectionString = ("Data Source=ALEX-LAPTOP\SQLEXPRESS;Initial Catalog=sldb;Integrated Security=True;Pooling=False") Dim updateAdapter As New SqlClient.SqlDataAdapter Dim sqlupdatequery = "UPDATE employee SET esr_no='" & txtEsr.Text & "', firstname='" & txtFirstname.Text & "', middlename='" & txtMiddlename.Text & "', lastname='" & txtLastname.Text & "', addressl1='" & txtAddress1.Text & "', addressl2='" & txtAddress2.Text & "', addressl3='" & txtAddress3.Text & "', addresscity='" & txtCity.Text & "', addresspostcode='" & txtPostcode.Text & "', addresscountry='" & txtCountry.Text & "', telephone='" & txtTelephone.Text & "', grade='" & cmbGrade.Text & "', speciality='" & cmbSpeciality.Text & "' WHERE sys_id='" & txtSysid.Text & "'" Dim updatecommand As New SqlClient.SqlCommand updatecommand.Connection = conn updatecommand.CommandText = sqlupdatequery updateAdapter.UpdateCommand = updatecommand conn.Open() updatecommand.ExecuteNonQuery() conn.Close() Me.txtEsr.ReadOnly = True Me.txtFirstname.ReadOnly = True Me.txtMiddlename.ReadOnly = True Me.txtLastname.ReadOnly = True Me.txtAddress1.ReadOnly = True Me.txtAddress2.ReadOnly = True Me.txtAddress3.ReadOnly = True Me.txtCity.ReadOnly = True Me.txtCountry.ReadOnly = True Me.txtPostcode.ReadOnly = True Me.txtTelephone.ReadOnly = True Me.cmbGrade.DropDownStyle = ComboBoxStyle.DropDownList Me.cmbSpeciality.DropDownStyle = ComboBoxStyle.DropDownList End Sub
Alex


Reply With Quote
