Alright, so my issue is that I have a staff profile. When you press the button it brings you to the Edit Profile page with text boxes with the original information in them so they can be edited. Now I ask for the edited information to be updated when the update button is clicked but it won't update. I know that I need to call new versions of the information from the text boxes but I'm not exactly sure how to go about this. I have use the "Request.Item" elsewhere in my code but you usually have to define a "Server.MapPath" which I'm not sure I can do in the confines of the update statement. Any help, hints, or ideas would be appreciated.
Also this is my first thread so if I do something wrong with the code tags please forgive me, I will learn quickly.
VB Code for the entire Staff Member Edit Profile Page below:
Dim MyCmd As String Sub Page_Load(ByVal s As Object, ByVal e As EventArgs) If Not Page.IsPostBack Then End If ' Create our Variables Dim MyConn As OleDbConnection Dim MyDA As OleDbDataAdapter Dim DS As DataSet Dim dvwEmployees As DataView ' Set up the DataView cache dvwEmployees = Cache("Employee") If dvwEmployees Is Nothing Then MyConn = New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\Christopher Carr\Documents\Visual Studio 2008\WebSites\MYTPSS new\tpsDatabase.accdb; Persist Security Info=False;") MyDA = New OleDbDataAdapter("Select * From Employee Where Employee_ID = " & Session.Item("userName") & " ", MyConn) DS = New DataSet() MyDA.Fill(DS, "Employee") dvwEmployees = DS.Tables("Employee").DefaultView() Cache("Employee") = dvwEmployees End If ' Display the information using labels lblWelcomeFName.Text = dvwEmployees(0).Row("First_Name") lblWelcomeLName.Text = dvwEmployees(0).Row("Last_Name") txtStaffID.Text = dvwEmployees(0).Row("Employee_ID") txtFirstName.Text = dvwEmployees(0).Row("First_Name") txtLastName.Text = dvwEmployees(0).Row("Last_Name") txtPhone.Text = dvwEmployees(0).Row("Phone") txtEmail.Text = dvwEmployees(0).Row("E-mail") txtAddress.Text = dvwEmployees(0).Row("Address") txtAvailability.Text = dvwEmployees(0).Row("Availability") End Sub Protected Sub btnUpdate_Click(ByVal sender As Object, ByVal e As System.EventArgs) Dim myTransaction As System.Data.OleDb.OleDbTransaction Try ' Declares connection and variables and opens connection to database Dim conn As New OleDbConnection("PROVIDER=Microsoft.ACE.OLEDB.12.0;" & _ "Data Source=C:\Users\Christopher Carr\Documents\Visual Studio 2008\WebSites\MYTPSS new\tpsDatabase.accdb") conn.Open() Dim command As OleDbCommand = conn.CreateCommand() Dim strSQL As String ' Adds and New Transaction myTransaction = conn.BeginTransaction ' Sets what strSQL display value is strSQL = "Update [Employee] Set First_Name = " & txtFirstName.Text & ", Last_Name = " & txtLastName.Text & ", Phone = " & txtPhone.Text & ", E-mail = " & txtEmail.Text & _ ", Address = " & txtAddress.Text & ", Availability = " & txtAvailability.Text & " Where Employee_ID = " & txtStaffID.Text & "" ' Gets a value indicating how the CommandText property is to be interpreted and CommandText is set equal to the strSQL value command.CommandType = CommandType.Text command.CommandText = strSQL ' Starts the transaction command.Transaction = myTransaction ' Performs the cataloging operations for update, insert and delete statements command.ExecuteNonQuery() ' Commits or saves transaction to the database myTransaction.Commit() ' Closes the connection to the database conn.Close() lblError.Text = "Your profile was successfully updated." Catch ex As Exception lblError.Text = "Your profile was unable to be updated." End Try End Sub
Edited 7 Years Ago by Kristofferson: Mistake in one of Data Sources