format issues using UPDATE command in MSACCESS

Last post 09-12-2005, 1:27 PM by ashleyaustin. 2 replies.
Sort Posts: Previous Next
  •  09-12-2005, 2:30 AM 10356

    format issues using UPDATE command in MSACCESS

    If I create a new record using a form that includes the cute editor it works.  When I call that record the cuteeditor populates the information properly.  When I click 'update' the information passed in the string looks like the text below.
     
    #1P#2#1#8TR#6NG #7tyl#9="C#6L#6R: #0ff00ff"#2Thi#7 i#7 n#5t g#5#5d.#1/#8TR#6NG#2#1/P#2

    The above is the exact text updated in the record.  When I go to update again the above text is populatied in the cuteeditor area of the form. 

    In the update_click code I am declaring the editor as:
    Dim
    OrganizationDescription = Request.Form.Item("OrganizationDescription")

    Dim sqlString  = "UPDATE community_outreach SET OrganizationDescription = '" & OrganizationDescription & "' WHERE (crID = " & crID & ")"

    Any advice? Thanks for your help.
  •  09-12-2005, 12:06 PM 10381 in reply to 10356

    Re: format issues using UPDATE command in MSACCESS

    Can you post more code which demonstrates the exact problem with more information?
     
    I have no idea now.
     
     

    asp.net Chat http://cutesoft.net/ASP.NET+Chat/default.aspx
    Web Messenger: http://cutesoft.net/Web-Messenger/default.aspx
    asp.net wysiwyg editor: http://cutesoft.net/ASP.NET+WYSIWYG+Editor/default.aspx
    asp wysiwyg html editor: http://cutesoft.net/ASP
    asp.net Image Gallery: http://cutesoft.net/ASP.NET+Image+Gallery/default.aspx
    Live Support: http://cutesoft.net/live-support/default.aspx

  •  09-12-2005, 1:27 PM 10399 in reply to 10381

    Re: format issues using UPDATE command in MSACCESS

    I am pasting the entire .aspx and aspx.vb pages below.   Again, the submit feature works fine (and the delete, but I don't think that applies here).  It is when I call the page with "edit=1" query string for the update feature the problem arises.  The form populates the information in the cuteeditor box, but it changes the information when I click submit.
     
    Here's the code and thanks for the help...
     
    <%@ Register TagPrefix="my" TagName="admin_header" src="includes/admin_header.ascx" %>
    <%@ Register TagPrefix="my" TagName="admin_footer" src="includes/admin_footer.ascx" %>
    <%@ Register TagPrefix="my" TagName="admin_nav" src="includes/admin_nav.ascx" %>
    <%@ Page Language="vb" AutoEventWireup="false" Codebehind="community_outreach_post_form.aspx.vb" Inherits="justout.WebForm1" %>
    <%@ Register TagPrefix="ce" Namespace="CuteEditor" Assembly="CuteEditor" %>
    <my:admin_header id="admin_header" runat="server"></my:admin_header>
    <TABLE id="Body Table" cellSpacing="0" cellPadding="0" width="750" align="center" border="0">
     <TR>
      <my:admin_nav id="admin_nav" runat="server"></my:admin_nav>
      <TD vAlign="top" align="center" bgColor="#ffffcc">
       <p style="FONT-WEIGHT: bold; FONT-SIZE: large">Community Outreach</p>
       <UL>
        <LI>
         <DIV align="left"><FONT size="2">Use this form to enter&nbsp;new Community and Outreach
           listings.</FONT>
         </DIV>
        <LI>
         <DIV align="left"><FONT size="2">If you want to edit an existing listing please choose
           'edit/delete existing' from the menu on the left.</FONT>
         </DIV>
        <LI>
         <DIV align="left"><FONT size="2">If you click submit, even once, then the information
           is no longer considered a new listing and will be available on the 'edit/delete
           existing' update page.</FONT></DIV>
        </LI>
       </UL>
       <form id="Form1" method="post" runat="server">
        <TABLE id="FormTable" style="Z-INDEX: 101; LEFT: 8px; TOP: 8px" cellSpacing="4" cellPadding="4"
         align="center" border="0">
         <TR>
          <TD vAlign="top" align="right">Location:</TD>
          <TD><asp:dropdownlist id="Location" runat="server">
            <asp:ListItem Value="Select Location">Select Location</asp:ListItem>
            <asp:ListItem Value="Portland Metro">Portland Metro
           </asp:ListItem>
            <asp:ListItem Value="Southern Oregon">Southern Oregon
           </asp:ListItem>
            <asp:ListItem Value="Coastal Oregon">Coastal Oregon
           </asp:ListItem>
            <asp:ListItem Value="Central Oregon">Central Oregon
           </asp:ListItem>
            <asp:ListItem Value="Eastern Oregon">Eastern Oregon
           </asp:ListItem>
            <asp:ListItem Value="Willamette Valley">Willamette Valley
           </asp:ListItem>
            <asp:ListItem Value="Washington">Washington</asp:ListItem>
           </asp:dropdownlist></TD>
         </TR>
         <TR>
          <TD vAlign="top" align="right">Category:</TD>
          <TD><asp:dropdownlist id="Category" runat="server">
            <asp:ListItem Value="Select Category">Select Category</asp:ListItem>
            <asp:ListItem Value="AIDS &amp; HIV">AIDS / HIV</asp:ListItem>
            <asp:ListItem Value="Anti-Violence">Anti-Violence</asp:ListItem>
            <asp:ListItem Value="Arts &amp; Music">Arts / Music
           </asp:ListItem>
            <asp:ListItem Value="Community">Community</asp:ListItem>
            <asp:ListItem Value="General">General</asp:ListItem>
            <asp:ListItem Value="Health">Health</asp:ListItem>
            <asp:ListItem Value="Mental Health">Mental Health</asp:ListItem>
            <asp:ListItem Value="Physical Recreation">Physical Recreation
           </asp:ListItem>
            <asp:ListItem Value="Political">Political</asp:ListItem>
            <asp:ListItem Value="Recovery">Recovery</asp:ListItem>
            <asp:ListItem Value="Sexual">Sexual</asp:ListItem>
            <asp:ListItem Value="Social">Social</asp:ListItem>
            <asp:ListItem Value="Spirituality">Spirituality</asp:ListItem>
            <asp:ListItem Value="Support">Support</asp:ListItem>
            <asp:ListItem Value="Youth">Youth</asp:ListItem>
           </asp:dropdownlist></TD>
         </TR>
         <TR>
          <TD vAlign="top" align="right">Name:</TD>
          <TD><asp:textbox id="OrganizationTitle1" runat="server" Width="250px"></asp:textbox><BR>
           <asp:textbox id="OrganizationTitle2" runat="server" Width="250px"></asp:textbox></TD>
         </TR>
         <TR>
          <TD vAlign="top" align="right">Description:</TD>
          <TD>
           <P>
            <CE:Editor id="OrganizationDescription" runat="server" Width="300px" Height="300px" AutoConfigure="Minimal"
             BreakElement="P">
             <FrameStyle Height="100%" BorderWidth="1px" BorderStyle="Solid" BorderColor="#C0C0C0" Width="100%"
              CssClass="CuteEditorFrame" BackColor="White"></FrameStyle>
            </CE:Editor></P>
          </TD>
         </TR>
         <TR>
          <TD vAlign="top" align="right">Address:</TD>
          <TD><asp:textbox id="StreetAddress1" runat="server" Width="250px"></asp:textbox><BR>
           <asp:textbox id="StreetAddress2" runat="server" Width="250px"></asp:textbox></TD>
         </TR>
         <TR>
          <TD vAlign="top" align="right" height="32">City:</TD>
          <TD height="32"><asp:textbox id="City" runat="server" Width="150px"></asp:textbox></TD>
         </TR>
         <TR>
          <TD vAlign="top" align="right">State:</TD>
          <TD><asp:dropdownlist id="State" runat="server">
            <asp:ListItem Value="Please Select">Please Select</asp:ListItem>
            <asp:ListItem Value="OR">Oregon</asp:ListItem>
            <asp:ListItem Value="WA">Washington</asp:ListItem>
           </asp:dropdownlist></TD>
         </TR>
         <TR>
          <TD vAlign="top" align="right">Zip:</TD>
          <TD><asp:textbox id="Zip" runat="server" Width="125px"></asp:textbox></TD>
         </TR>
         <TR>
          <TD vAlign="top" align="right">Phone:</TD>
          <TD><asp:textbox id="Phone" runat="server" Width="125px"></asp:textbox></TD>
         </TR>
         <TR>
          <TD vAlign="top" align="right">Email:</TD>
          <TD><asp:textbox id="Email" runat="server" Width="250px"></asp:textbox></TD>
         </TR>
         <TR>
          <TD vAlign="top" align="right">Web:</TD>
          <TD><asp:textbox id="Web" runat="server" Width="250px"></asp:textbox></TD>
         </TR>
         <TR>
          <TD vAlign="top" align="right"><INPUT id="community_outreachID" type="hidden" size="3" name="community_outreachID" runat="server"></TD>
          <TD><asp:button id="Submit" runat="server" Text="Submit"></asp:button>
           <asp:Button id="Update" runat="server" Text="Update"></asp:Button>
           <asp:Button id="Delete" runat="server" Text="THIS IS A DELETE KEY" Visible="False"></asp:Button></TD>
         </TR>
        </TABLE>
       </form>
      </TD>
     </TR>
    </TABLE>
    <my:admin_footer id="admin_footer" runat="server"></my:admin_footer>
     

    ////// Below is the code behind page /////
    Imports System.Data
    Imports System.Data.OleDb
    Imports CuteEditor
    Public Class WebForm1
        Inherits System.Web.UI.Page
    #Region " Web Form Designer Generated Code "
        'This call is required by the Web Form Designer.
        <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
            Me.OleDbConnection1 = New System.Data.OleDb.OleDbConnection
            '
            'OleDbConnection1
            '
            Me.OleDbConnection1.ConnectionString = "Jet OLEDB:Global Partial Bulk Ops=2;Jet OLEDB:Registry Path=;Jet OLEDB:Database L" & _
            "ocking Mode=1;Jet OLEDB:Database Password=;Data Source=""C:\Inetpub\dbases\justou" & _
            "t1.mdb"";Password=;Jet OLEDB:Engine Type=5;Jet OLEDB:Global Bulk Transactions=1;P" & _
            "rovider=""Microsoft.Jet.OLEDB.4.0"";Jet OLEDB:System database=;Jet OLEDB:SFP=False" & _
            ";Extended Properties=;Mode=Share Deny None;Jet OLEDB:New Database Password=;Jet " & _
            "OLEDB:Create System Database=False;Jet OLEDB:Don't Copy Locale on Compact=False;" & _
            "Jet OLEDB:Compact Without Replica Repair=False;User ID=Admin;Jet OLEDB:Encrypt D" & _
            "atabase=False"
        End Sub
        Protected WithEvents objCommand As System.Data.OleDb.OleDbCommand
        Protected WithEvents Location As System.Web.UI.WebControls.DropDownList
        Protected WithEvents Category As System.Web.UI.WebControls.DropDownList
        Protected WithEvents StreetAddress1 As System.Web.UI.WebControls.TextBox
        Protected WithEvents StreetAddress2 As System.Web.UI.WebControls.TextBox
        Protected WithEvents City As System.Web.UI.WebControls.TextBox
        Protected WithEvents State As System.Web.UI.WebControls.DropDownList
        Protected WithEvents Zip As System.Web.UI.WebControls.TextBox
        Protected WithEvents Phone As System.Web.UI.WebControls.TextBox
        Protected WithEvents Email As System.Web.UI.WebControls.TextBox
        Protected WithEvents Web As System.Web.UI.WebControls.TextBox
        Protected WithEvents Submit As System.Web.UI.WebControls.Button
        Protected WithEvents OrganizationTitle1 As System.Web.UI.WebControls.TextBox
        Protected WithEvents OrganizationTitle2 As System.Web.UI.WebControls.TextBox
        Public WithEvents OleDbConnection1 As System.Data.OleDb.OleDbConnection
        Protected WithEvents Form1 As System.Web.UI.HtmlControls.HtmlForm
        Protected WithEvents OrganizationDescription As CuteEditor.Editor
        Protected WithEvents community_outreachID As System.Web.UI.HtmlControls.HtmlInputHidden
        Protected WithEvents Update As System.Web.UI.WebControls.Button
        Protected WithEvents Delete As System.Web.UI.WebControls.Button

        'NOTE: The following placeholder declaration is required by the Web Form Designer.
        'Do not delete or move it.
        Private designerPlaceholderDeclaration As System.Object
        Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
            'CODEGEN: This method call is required by the Web Form Designer
            'Do not modify it using the code editor.
            InitializeComponent()
        End Sub
    #End Region
        Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            'Put user code to initialize the page here
            Dim Edit = Request.QueryString("Edit")
            Dim Delete = Request.QueryString("Delete")
            Dim id = Request.QueryString("id")
            If Edit = "1" Then
                Me.OleDbConnection1.Open()
                Dim sqlString = "Select * FROM community_outreach WHERE community_outreachID = " & id
                Dim cmd As OleDb.OleDbCommand = New OleDb.OleDbCommand(sqlString, Me.OleDbConnection1)
                Dim rdr As OleDbDataReader
                rdr = cmd.ExecuteReader
                Me.Submit.Visible = False
                Me.Update.Visible = True
                Me.Delete.Visible = False
                While rdr.Read
                    Me.community_outreachID.Value = rdr.Item("community_outreachID")
                    Me.Location.SelectedValue = rdr.Item("Location")
                    Me.Category.SelectedValue = rdr.Item("Category")
                    Me.OrganizationTitle1.Text = rdr.Item("OrganizationTitle1")
                    Me.OrganizationTitle2.Text = rdr.Item("OrganizationTitle2")
                    Me.OrganizationDescription.Text = rdr.Item("OrganizationDescription")
                    Me.StreetAddress1.Text = rdr.Item("StreetAddress1")
                    Me.StreetAddress2.Text = rdr.Item("StreetAddress2")
                    Me.City.Text = rdr.Item("City")
                    Me.State.SelectedValue = rdr.Item("State")
                    Me.Zip.Text = rdr.Item("Zip")
                    Me.Phone.Text = rdr.Item("Phone")
                    Me.Email.Text = rdr.Item("Email")
                    Me.Web.Text = rdr.Item("Web")
                End While
                Me.OleDbConnection1.Close()
            End If
            If Delete = "1" Then
                Me.OleDbConnection1.Open()
                Dim sqlString = "Select * FROM community_outreach WHERE community_outreachID = " & id
                Dim cmd As OleDb.OleDbCommand = New OleDb.OleDbCommand(sqlString, Me.OleDbConnection1)
                Dim rdr As OleDbDataReader
                rdr = cmd.ExecuteReader
                Me.Submit.Visible = False
                Me.Update.Visible = False
                Me.Delete.Visible = True
                While rdr.Read
                    Me.community_outreachID.Value = rdr.Item("community_outreachID")
                    Me.Location.SelectedValue = rdr.Item("Location")
                    Me.Category.SelectedValue = rdr.Item("Category")
                    Me.OrganizationTitle1.Text = rdr.Item("OrganizationTitle1")
                    Me.OrganizationTitle2.Text = rdr.Item("OrganizationTitle2")
                    Me.OrganizationDescription.Text = rdr.Item("OrganizationDescription")
                    Me.StreetAddress1.Text = rdr.Item("StreetAddress1")
                    Me.StreetAddress2.Text = rdr.Item("StreetAddress2")
                    Me.City.Text = rdr.Item("City")
                    Me.State.SelectedValue = rdr.Item("State")
                    Me.Zip.Text = rdr.Item("Zip")
                    Me.Phone.Text = rdr.Item("Phone")
                    Me.Email.Text = rdr.Item("Email")
                    Me.Web.Text = rdr.Item("Web")
                End While
                Me.OleDbConnection1.Close()
            End If
        End Sub
        Private Sub Submit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Submit.Click
            Dim Location = Me.Location.SelectedValue.ToString()
            Dim Category = Me.Category.SelectedValue.ToString()
            Dim OrganizationTitle1 = Me.OrganizationTitle1.Text.ToString()
            Dim OrganizationTitle2 = Me.OrganizationTitle2.Text.ToString()
            Dim OrganizationDescription = Me.OrganizationDescription.Text.ToString()
            Dim StreetAddress1 = Me.StreetAddress1.Text.ToString()
            Dim StreetAddress2 = Me.StreetAddress2.Text.ToString()
            Dim City = Me.City.Text.ToString()
            Dim State = Me.State.SelectedValue.ToString()
            Dim Zip = Me.Zip.Text.ToString()
            Dim Phone = Me.Phone.Text.ToString()
            Dim Email = Me.Email.Text.ToString()
            Dim Web = Me.Web.Text.ToString()
            'Try
            Me.OleDbConnection1.Open()
            Dim sqlString = "Insert Into community_outreach (Location,Category,OrganizationTitle1,OrganizationTitle2,OrganizationDescription,StreetAddress1,StreetAddress2,City,State,Zip,Phone,Email,Web) values ('" & Location & "','" & Category & "','" & OrganizationTitle1 & "','" & OrganizationTitle2 & "','" & OrganizationDescription & "','" & StreetAddress1 & "','" & StreetAddress2 & "','" & City & "','" & State & "','" & Zip & "','" & Phone & "','" & Email & "','" & Web & "')"
            Dim cmd As OleDb.OleDbCommand = New OleDb.OleDbCommand(sqlString, Me.OleDbConnection1)
            cmd.ExecuteNonQuery()
            Me.OleDbConnection1.Close()
            Me.OleDbConnection1.Dispose() 'Do I need a dispose?
            'Catch ex As Exception
            'End Try
        End Sub
        Private Sub Update_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Update.Click
            Dim community_outreachID = Me.community_outreachID.Value
            Dim Location = Request.Form.Item("Location")
            Dim Category = Request.Form.Item("Category")
            Dim UpdateOrganizationTitle1 = Request.Form.Item("OrganizationTitle1")
            Dim OrganizationTitle2 = Request.Form.Item("OrganizationTitle2")
            Dim OrganizationDescription = Request.Form.Item("OrganizationDescription")
            'Dim OrganizationDescription = Request.Form.Item("OrganizationDescription")
            Dim StreetAddress1 = Request.Form.Item("StreetAddress1")
            Dim StreetAddress2 = Request.Form.Item("StreetAddress2")
            Dim City = Request.Form.Item("City")
            Dim State = Request.Form.Item("State")
            Dim Zip = Request.Form.Item("Zip")
            Dim Phone = Request.Form.Item("Phone")
            Dim Email = Request.Form.Item("Email")
            Dim Web = Request.Form.Item("Web")
     
            Me.OleDbConnection1.Open()
            Dim sqlString = "UPDATE community_outreach SET Location = '" & Location & "', Category = '" & Category & "', OrganizationTitle1 = '" & UpdateOrganizationTitle1 & "', OrganizationTitle2 = '" & OrganizationTitle2 & "', OrganizationDescription = '" & OrganizationDescription & "', StreetAddress1 = '" & StreetAddress1 & "', StreetAddress2 = '" & StreetAddress2 & "', City = '" & City & "', State = '" & State & "', Zip = '" & Zip & "', Phone = '" & Phone & "', Email = '" & Email & "', Web = '" & Web & "'  WHERE (community_outreachID = " & community_outreachID & " )"
            Dim cmd As OleDb.OleDbCommand = New OleDb.OleDbCommand(sqlString, Me.OleDbConnection1)
            cmd.ExecuteNonQuery()
            Me.OleDbConnection1.Close()
        End Sub
        Private Sub Delete_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Delete.Click

            Me.OleDbConnection1.Open()
            Dim community_outreachID = Me.community_outreachID.Value
            Dim sqlString = "DELETE FROM community_outreach WHERE (community_outreachID = " & community_outreachID & ")"
            Dim cmd As OleDb.OleDbCommand = New OleDb.OleDbCommand(sqlString, Me.OleDbConnection1)
            cmd.ExecuteNonQuery()
            Me.OleDbConnection1.Close()
     
        End Sub
    End Class
View as RSS news feed in XML