franky_25
August 30th, 2004, 02:56 PM
Hey guys,
I need help...
i am creating a web page which can display employee details and modify it.I have no problems displaying data in the grid as well as adding data into the database.
I wanted to modify data from the database,so what i did was create an edit button in the display employee details grid which when clicked would open up a new page which would display all the relevant data in text boxes and other elements.Now heres where the problem occurs when i click on the update button nothing happens...
this is the code that i wrote to display data from grid into text boxes
sub edit_det()
txtEmployeeID.Text = Request.Params("empid")
Dim str As String = "Select * from employees where employeeID= '" & txtEmployeeID.Text & "'"
Dim con As New SqlConnection(constr)
Dim cmd As New SqlCommand(str, con)
Dim da As New SqlDataAdapter(cmd)
Dim ds As New DataSet()
da.Fill(ds, "employees")
txtFirstName.Text = ds.Tables("employees").Rows(0)("FirstName")
txtlastname.Text = ds.Tables("employees").Rows(0)("Lastname")
txtTitleOfCourtesy.Text = ds.Tables("employees").Rows(0)("TitleOfCourtesy")
txtBirthDate.Text = ds.Tables("employees").Rows(0)("BirthDate")
txthiredate.Text = ds.Tables("employees").Rows(0)("hiredate")
txtCity.Text = ds.Tables("employees").Rows(0)("City")
txtPostalCode.Text = ds.Tables("employees").Rows(0)("PostalCode")
txtCountry.Text = ds.Tables("employees").Rows(0)("Country")
txtHomePhone.Text = ds.Tables("employees").Rows(0)("HomePhone")
txttitle.Text = ds.Tables("employees").Rows(0)("Title")
txtAddress.Text = ds.Tables("employees").Rows(0)("Address")
con.Close()
the above code works perfectly alright
and this is the code that I wrote on the click event of the update button...
this part doesnt work...
Dim con As New SqlConnection(constr)
Dim str As String = "Select * from employees"
Dim da As New SqlDataAdapter(str, con)
Dim cmd As New SqlCommandBuilder(da)
Dim ds As New DataSet()
da.Fill(ds, "employees")ds.Tables("employees").Rows(0)("FirstName") = txtFirstName.Text
ds.Tables("employees").Rows(0)("LastName") = txtlastname.Text
....
....
....
da.Update(ds, "employees")
Response.Redirect("employee.aspx"
Please help me....
any help would be appriciated...
Frank
I need help...
i am creating a web page which can display employee details and modify it.I have no problems displaying data in the grid as well as adding data into the database.
I wanted to modify data from the database,so what i did was create an edit button in the display employee details grid which when clicked would open up a new page which would display all the relevant data in text boxes and other elements.Now heres where the problem occurs when i click on the update button nothing happens...
this is the code that i wrote to display data from grid into text boxes
sub edit_det()
txtEmployeeID.Text = Request.Params("empid")
Dim str As String = "Select * from employees where employeeID= '" & txtEmployeeID.Text & "'"
Dim con As New SqlConnection(constr)
Dim cmd As New SqlCommand(str, con)
Dim da As New SqlDataAdapter(cmd)
Dim ds As New DataSet()
da.Fill(ds, "employees")
txtFirstName.Text = ds.Tables("employees").Rows(0)("FirstName")
txtlastname.Text = ds.Tables("employees").Rows(0)("Lastname")
txtTitleOfCourtesy.Text = ds.Tables("employees").Rows(0)("TitleOfCourtesy")
txtBirthDate.Text = ds.Tables("employees").Rows(0)("BirthDate")
txthiredate.Text = ds.Tables("employees").Rows(0)("hiredate")
txtCity.Text = ds.Tables("employees").Rows(0)("City")
txtPostalCode.Text = ds.Tables("employees").Rows(0)("PostalCode")
txtCountry.Text = ds.Tables("employees").Rows(0)("Country")
txtHomePhone.Text = ds.Tables("employees").Rows(0)("HomePhone")
txttitle.Text = ds.Tables("employees").Rows(0)("Title")
txtAddress.Text = ds.Tables("employees").Rows(0)("Address")
con.Close()
the above code works perfectly alright
and this is the code that I wrote on the click event of the update button...
this part doesnt work...
Dim con As New SqlConnection(constr)
Dim str As String = "Select * from employees"
Dim da As New SqlDataAdapter(str, con)
Dim cmd As New SqlCommandBuilder(da)
Dim ds As New DataSet()
da.Fill(ds, "employees")ds.Tables("employees").Rows(0)("FirstName") = txtFirstName.Text
ds.Tables("employees").Rows(0)("LastName") = txtlastname.Text
....
....
....
da.Update(ds, "employees")
Response.Redirect("employee.aspx"
Please help me....
any help would be appriciated...
Frank