The process cannot access the file

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • vertigo262
    New Member
    • Jul 2007
    • 62

    #1

    The process cannot access the file

    I don't know why this does this on the delete.

    any ideas?


    line 289


    ---------------------------------------------
    The process cannot access the file 'D:\InetPub\Ree fJunkies\Users\ bill\Profile\Pi ctureThumb\340x _la-rouxsmall.jpg' because it is being used by another process.
    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    Exception Details: System.IO.IOExc eption: The process cannot access the file 'D:\InetPub\Ree fJunkies\Users\ bill\Profile\Pi ctureThumb\340x _la-rouxsmall.jpg' because it is being used by another process.

    Source Error:

    Line 174: Dim fd2 As New FileInfo(OldPat h2)
    Line 175: If fd2.Exists = True Then
    Line 176: fd2.Delete()
    Line 177: End If
    Line 178: End If

    ---------------------------------------------



    Code:
    insertion code
    
    
    
    
                'upload picture
                Dim PictureThumbpass
                Dim PicturePass
    
                Dim fileLen As Integer
                Dim myStream As System.IO.Stream
                Dim ImgContentType As String
                Dim UserName = NickName.Text
    
                Dim FileUploadPicture As FileUpload = FileUploadProfilePhoto
    
                'Response.Write(FileUploadPicture.HasFile)
                'Response.End()
    
                If FileUploadPicture.HasFile Then
                    'Create Dir
                    Dim nd As New DirectoryInfo(Server.MapPath("\" + Application("SysUserDir") & "\" & UserName & "\Profile\Picture\"))
                    If nd.Exists = False Then
                        nd.Create()
                    End If
    
                    'Create Dir
                    Dim nd2 As New DirectoryInfo(Server.MapPath("\" + Application("SysUserDir") & "\" & UserName & "\Profile\PictureThumb\"))
                    If nd2.Exists = False Then
                        nd2.Create()
                    End If
    
    
    
                    fileLen = FileUploadPicture.PostedFile.ContentLength
                    ImgContentType = FileUploadPicture.PostedFile.ContentType
    
                    Dim Input(fileLen) As Byte
                    myStream = FileUploadPicture.PostedFile.InputStream
                    myStream.Read(Input, 0, fileLen)
    
                    'Response.Write(fileLen)
                    'Response.End()
    
                    Dim Filename = FileUploadPicture.PostedFile.FileName
    
                    Dim Path1 = Server.MapPath("\" + Application("SysUserDir") & "\" & UserName & "\Profile\Picture\" & Filename)
                    Dim DataPath1 = "/" & UserName & "/Profile/Picture/" & Filename
    
                    Dim Path2 = Server.MapPath("\" + Application("SysUserDir") & "\" & UserName & "\Profile\PictureThumb\" & Filename)
                    Dim DataPath2 = "/" & UserName & "/Profile/PictureThumb/" & Filename
    
    
                    If File.Exists(Path1) Or File.Exists(Path2) Then
    
                        'LabelPhotos.Text = "Photo has not been added to the system"
                        'LabelConfirm.Text = "This photo image already exists in the system"
                        LabelRegisterDone.Text = "<h2><font color=#FF0000>Registration Failure</font></h2><br>This File Already Exists<br><br>"
                        MultiViewRegister.SetActiveView(ViewRegisterDone)
                        e.Cancel = True
    
                    Else
    
    
    
                        'LabelConfirm.Text = ""
                        Dim PictureInfoLarge = System.Drawing.Image.FromStream(myStream)
    
    
    
    
                        'Get Picture To be Resized large
                        Dim maxWidth1 As Integer = 800
                        Dim maxHeight1 As Integer = 800
                        Dim imgHeight1, imgWidth1 As Integer
                        'Dim PictureInfo
    
    
    
                        imgHeight1 = PictureInfoLarge.Height
                        imgWidth1 = PictureInfoLarge.Width
    
    
                        ' Determine Scaling
                        If imgWidth1 >= maxWidth1 Or imgHeight1 >= maxHeight1 Then
                            'Determine what dimension is off by more
                            Dim deltaWidth1 As Integer = imgWidth1 - maxWidth1
                            Dim deltaHeight1 As Integer = imgHeight1 - maxHeight1
                            Dim scaleFactor1 As Double
    
                            If deltaHeight1 > deltaWidth1 Then
                                'Scale by the height
                                scaleFactor1 = maxHeight1 / imgHeight1
                            Else
                                'Scale by the Width
                                scaleFactor1 = maxWidth1 / imgWidth1
                            End If
    
                            imgWidth1 *= scaleFactor1
                            imgHeight1 *= scaleFactor1
    
                        Else
    
    
                        End If
    
                        'Dim objThumbnail As System.Drawing.Image = PictureInfoLarge.GetThumbnailImage(imgWidth1, imgHeight1, Nothing, System.IntPtr.Zero)
                        Dim objThumbnail As System.Drawing.Bitmap = PictureInfoLarge.GetThumbnailImage(imgWidth1, imgHeight1, Nothing, System.IntPtr.Zero)
                        ' Dim graphicsImage As System.Drawing.Graphics = System.Drawing.Graphics.FromImage(objThumbnail)
    
                        '---------------supposed to fix -----------------------------------
                        Dim graphicsImage As Graphics
                        graphicsImage = Graphics.FromImage(objThumbnail)
                        graphicsImage.SmoothingMode = Drawing.Drawing2D.SmoothingMode.HighQuality
                        graphicsImage.InterpolationMode = Drawing2D.InterpolationMode.HighQualityBicubic
                        graphicsImage.DrawImage(objThumbnail, 0, 0, imgWidth1, imgHeight1)
                        '--------------------------------------------------------------------
                        graphicsImage.Save()
    
                        objThumbnail.Save(Path1, Imaging.ImageFormat.Jpeg)
    
    
                        graphicsImage.Dispose()
    
                        PicturePass = DataPath1
                        'e.Values("Picture") = DataPath1
    
                        PictureInfoLarge = Nothing
                        objThumbnail = Nothing
    
    
                        Dim PictureInfoSmall = System.Drawing.Image.FromStream(myStream)
    
    
                        'Get Picture To be Resized small
                        Dim maxWidth2 = 150
                        Dim maxHeight2 = 150
                        'imgHeight, imgWidth As Integer
                        'Dim PictureInfo
    
    
    
                        Dim imgHeight2 = PictureInfoSmall.Height
                        Dim imgWidth2 = PictureInfoSmall.Width
    
                        ' Determine Scaling
                        If imgWidth2 >= maxWidth2 Or imgHeight2 >= maxHeight2 Then
                            'Determine what dimension is off by more
                            ' Dim deltaWidth As Integer = imgWidth - maxWidth
                            'Dim deltaHeight As Integer = imgHeight - maxHeight
                            ' Dim scaleFactor As Double
                            Dim deltaWidth2 As Integer = imgWidth2 - maxWidth2
                            Dim deltaHeight2 As Integer = imgHeight2 - maxHeight2
                            Dim scaleFactor2 As Double
    
                            If deltaHeight2 > deltaWidth2 Then
                                'Scale by the height
                                scaleFactor2 = maxHeight2 / imgHeight2
                            Else
                                'Scale by the Width
                                scaleFactor2 = maxWidth2 / imgWidth2
                            End If
    
                            imgWidth2 *= scaleFactor2
                            imgHeight2 *= scaleFactor2
    
                        Else
    
                        End If
    
    
                        Dim objThumbnail2 As System.Drawing.Bitmap = PictureInfoSmall.GetThumbnailImage(imgWidth2, imgHeight2, Nothing, System.IntPtr.Zero)
    
                        '---------------supposed to fix -----------------------------------
                        Dim graphicsImage2 As Graphics
                        graphicsImage2 = Graphics.FromImage(objThumbnail2)
                        graphicsImage2.SmoothingMode = Drawing.Drawing2D.SmoothingMode.HighQuality
                        graphicsImage2.InterpolationMode = Drawing2D.InterpolationMode.HighQualityBicubic
                        graphicsImage2.DrawImage(objThumbnail2, 0, 0, imgWidth2, imgHeight2)
                        '--------------------------------------------------------------------
                        graphicsImage2.Save()
    
                        objThumbnail2.Save(Path2, Imaging.ImageFormat.Jpeg)
    
                        graphicsImage2.Dispose()
    
                        PictureThumbpass = DataPath2
                        'e.Values("PictureThumb") = DataPath2
    
    
                        myStream.Close()
                        myStream.Dispose()
    
                        PictureInfoSmall = Nothing
                        objThumbnail2 = Nothing
    
    
    
    
    
    
    
                    End If
    
    
                ElseIf Not FileUploadPicture.HasFile Then
    
    
                End If
    
    
    
    Update Code, almost the same
    
    
    
    
    
    
    
    
    
    
      Protected Sub SuperFormPersonalInformation_ItemUpdating(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DetailsViewUpdateEventArgs) Handles SuperFormPersonalInformation.ItemUpdating
    
    
    
            Dim fileLen As Integer
            Dim myStream As System.IO.Stream
            Dim ImgContentType As String
            Dim UserName = Dal.GetNickName(Dal.GetUserID)
    
            Dim FileUploadPicture As FileUpload = SuperFormPersonalInformation.FindControl("FileUploadEditPicture")
    
            'Response.Write(FileUploadPicture.HasFile)
            'Response.End()
    
            If FileUploadPicture.HasFile Then
                'Create Dir
                Dim nd As New DirectoryInfo(Server.MapPath("\" + Application("SysUserDir") & "\" & UserName & "\Profile\Picture\"))
                If nd.Exists = False Then
                    nd.Create()
                End If
    
                'Create Dir
                Dim nd2 As New DirectoryInfo(Server.MapPath("\" + Application("SysUserDir") & "\" & UserName & "\Profile\PictureThumb\"))
                If nd2.Exists = False Then
                    nd2.Create()
                End If
    
    
    
                fileLen = FileUploadPicture.PostedFile.ContentLength
                ImgContentType = FileUploadPicture.PostedFile.ContentType
    
                Dim Input(fileLen) As Byte
                myStream = FileUploadPicture.PostedFile.InputStream
                myStream.Read(Input, 0, fileLen)
    
                'Response.Write(fileLen)
                'Response.End()
    
                Dim Filename = FileUploadPicture.PostedFile.FileName
    
                Dim Path1 = Server.MapPath("\" + Application("SysUserDir") & "\" & UserName & "\Profile\Picture\" & Filename)
                Dim DataPath1 = "/" & UserName & "/Profile/Picture/" & Filename
                Dim OldPath1 = Server.MapPath("/" & Application("SysUserDir") & "/" & e.OldValues("Picture"))
    
                Dim Path2 = Server.MapPath("\" + Application("SysUserDir") & "\" & UserName & "\Profile\PictureThumb\" & Filename)
                Dim DataPath2 = "/" & UserName & "/Profile/PictureThumb/" & Filename
                Dim OldPath2 = Server.MapPath("/" & Application("SysUserDir") & "/" & e.OldValues("PictureThumb"))
    
    
                'Response.Write(DataPath1 & " " & DataPath2)
                'Response.End()
                'delete old image
    
                'delete old files
                If FileUploadPicture.HasFile Then
                    Dim fd1 As New FileInfo(OldPath1)
                    If fd1.Exists = True Then
                        fd1.Delete()
                    End If
                End If
    
                If FileUploadPicture.HasFile Then
                    Dim fd2 As New FileInfo(OldPath2)
                    If fd2.Exists = True Then
                        fd2.Delete()
                    End If
                End If
    
    
    
    
    
                If File.Exists(Path1) Or File.Exists(Path2) Then
    
                    'LabelPhotos.Text = "Photo has not been added to the system"
                    LabelConfirmPersonalInfo.Text = "This photo image already exists in the system"
                    e.Cancel = True
    
                Else
    
    
    
                    LabelConfirmPersonalInfo.Text = ""
                    Dim PictureInfoLarge = System.Drawing.Image.FromStream(myStream)
    
    
    
    
                    'Get Picture To be Resized large
                    Dim maxWidth1 As Integer = 800
                    Dim maxHeight1 As Integer = 800
                    Dim imgHeight1, imgWidth1 As Integer
                    'Dim PictureInfo
    
    
    
                    imgHeight1 = PictureInfoLarge.Height
                    imgWidth1 = PictureInfoLarge.Width
    
    
                    ' Determine Scaling
                    If imgWidth1 >= maxWidth1 Or imgHeight1 >= maxHeight1 Then
                        'Determine what dimension is off by more
                        Dim deltaWidth1 As Integer = imgWidth1 - maxWidth1
                        Dim deltaHeight1 As Integer = imgHeight1 - maxHeight1
                        Dim scaleFactor1 As Double
    
                        If deltaHeight1 > deltaWidth1 Then
                            'Scale by the height
                            scaleFactor1 = maxHeight1 / imgHeight1
                        Else
                            'Scale by the Width
                            scaleFactor1 = maxWidth1 / imgWidth1
                        End If
    
                        imgWidth1 *= scaleFactor1
                        imgHeight1 *= scaleFactor1
    
                    Else
    
    
                    End If
    
                    'Dim objThumbnail As System.Drawing.Image = PictureInfoLarge.GetThumbnailImage(imgWidth1, imgHeight1, Nothing, System.IntPtr.Zero)
                    Dim objThumbnail As System.Drawing.Bitmap = PictureInfoLarge.GetThumbnailImage(imgWidth1, imgHeight1, Nothing, System.IntPtr.Zero)
                    ' Dim graphicsImage As System.Drawing.Graphics = System.Drawing.Graphics.FromImage(objThumbnail)
    
                    '---------------supposed to fix -----------------------------------
                    Dim graphicsImage As Graphics
                    graphicsImage = Graphics.FromImage(objThumbnail)
                    graphicsImage.SmoothingMode = Drawing.Drawing2D.SmoothingMode.HighQuality
                    graphicsImage.InterpolationMode = Drawing2D.InterpolationMode.HighQualityBicubic
                    graphicsImage.DrawImage(objThumbnail, 0, 0, imgWidth1, imgHeight1)
                    '--------------------------------------------------------------------
                    graphicsImage.Save()
    
                    objThumbnail.Save(Path1, Imaging.ImageFormat.Jpeg)
    
                    'Response.Write(objThumbnail.PixelFormat & "<BR><BR>")
                    'Response.Write(objThumbnail.PhysicalDimension)
                    'Response.Write(objThumbnail.Size)
    
                    'Response.End()
    
    
                    graphicsImage.Dispose()
    
                    e.NewValues("Picture") = DataPath1
    
                    PictureInfoLarge = Nothing
                    objThumbnail = Nothing
    
    
                    Dim PictureInfoSmall = System.Drawing.Image.FromStream(myStream)
    
    
                    'Get Picture To be Resized small
                    Dim maxWidth2 = 150
                    Dim maxHeight2 = 150
                    'imgHeight, imgWidth As Integer
                    'Dim PictureInfo
    
    
    
                    Dim imgHeight2 = PictureInfoSmall.Height
                    Dim imgWidth2 = PictureInfoSmall.Width
    
                    ' Determine Scaling
                    If imgWidth2 >= maxWidth2 Or imgHeight2 >= maxHeight2 Then
                        'Determine what dimension is off by more
                        ' Dim deltaWidth As Integer = imgWidth - maxWidth
                        'Dim deltaHeight As Integer = imgHeight - maxHeight
                        ' Dim scaleFactor As Double
                        Dim deltaWidth2 As Integer = imgWidth2 - maxWidth2
                        Dim deltaHeight2 As Integer = imgHeight2 - maxHeight2
                        Dim scaleFactor2 As Double
    
                        If deltaHeight2 > deltaWidth2 Then
                            'Scale by the height
                            scaleFactor2 = maxHeight2 / imgHeight2
                        Else
                            'Scale by the Width
                            scaleFactor2 = maxWidth2 / imgWidth2
                        End If
    
                        imgWidth2 *= scaleFactor2
                        imgHeight2 *= scaleFactor2
    
                    Else
    
                    End If
    
    
                    Dim objThumbnail2 As System.Drawing.Bitmap = PictureInfoSmall.GetThumbnailImage(imgWidth2, imgHeight2, Nothing, System.IntPtr.Zero)
    
                    '---------------supposed to fix -----------------------------------
                    Dim graphicsImage2 As Graphics
                    graphicsImage2 = Graphics.FromImage(objThumbnail2)
                    graphicsImage2.SmoothingMode = Drawing.Drawing2D.SmoothingMode.HighQuality
                    graphicsImage2.InterpolationMode = Drawing2D.InterpolationMode.HighQualityBicubic
                    graphicsImage2.DrawImage(objThumbnail2, 0, 0, imgWidth2, imgHeight2)
                    '--------------------------------------------------------------------
                    graphicsImage2.Save()
    
                    objThumbnail2.Save(Path2, Imaging.ImageFormat.Jpeg)
    
                    graphicsImage2.Dispose()
    
    
                    e.NewValues("PictureThumb") = DataPath2
    
    
                    myStream.Close()
                    myStream.Dispose()
    
                    PictureInfoSmall = Nothing
                    objThumbnail2 = Nothing
    
    
    
    
    
    
    
                End If
    
    
            ElseIf Not FileUploadPicture.HasFile Then
    
                'Dim PictureOld = CType(SuperFormAquariums.FindControl("HiddenFieldPictureEdit"), HiddenField).Value
                'Dim PictureThumbOld = CType(SuperFormAquariums.FindControl("HiddenFieldPictureThumbedit"), HiddenField).Value
                'Response.Write("new:" & e.NewValues("Picture") & " " & e.NewValues("PictureThumb") & " OLD: " & e.OldValues("Picture") & " " & e.OldValues("PictureThumb"))
                'Response.End()
    
                e.NewValues("Picture") = e.OldValues("Picture")
    
                e.NewValues("PictureThumb") = e.OldValues("PictureThumb")
    
            End If
    
    
        End Sub

    any help would be appreciated
  • Frinavale
    Recognized Expert Expert
    • Oct 2006
    • 9749

    #2
    This error will occur if you have not closed all streams and other objects that use the file after you are finished with it. Go through your code and make sure that you ensure that this is done.

    -Frinny

    Comment

    • vertigo262
      New Member
      • Jul 2007
      • 62

      #3
      Hi Frinny ,

      I only have one stream, and I'm closing it at the end. unless I'm missing something

      Comment

      • vertigo262
        New Member
        • Jul 2007
        • 62

        #4
        I noticed that the image that I'm trying to delete is open in the web browser at the time of deletion. Could that be the problem? if so, what is the fix for that

        live code



        login: bill
        password: bill

        Comment

        • vertigo262
          New Member
          • Jul 2007
          • 62

          #5
          OK, found where the glitch is

          Code:
           <obout:SuperForm ID="SuperFormPersonalInformation" runat="server" AutoGenerateEditButton="True" 
                                              DataKeyNames="UserAccountsID" AutoGenerateRows="False" Width="100%"  
                                                  HorizontalAlign="Center" DataSourceID="ObjectDataSourcePersonalInfo" 
                                                  BorderColor="#AEADAD" BorderStyle="Solid" BorderWidth="1px" 
                                                  HeaderStyle-BorderColor="#AEADAD" HeaderStyle-BorderStyle="Solid" 
                                                  HeaderStyle-BorderWidth="1" AllowDataKeysInsert="False" GridLines="Both">
                                              
                                              <Fields>
                                                  <obout:BoundField DataField="NickName" HeaderText="NickName:" SortExpression="NickName" ControlStyle-Width="200" Required="False" ControlStyle-ForeColor="Red" />
                                                  <obout:BoundField DataField="FirstName" HeaderText="First Name:" SortExpression="FirstName" ControlStyle-Width="300" Required="False" ControlStyle-ForeColor="Red" />
                                                  <obout:BoundField DataField="LastName" HeaderText="Last Name:" SortExpression="LastName" ControlStyle-Width="300" Required="False" ControlStyle-ForeColor="Red" />
                                                      <obout:TemplateField>
                                                          <EditItemTemplate>
                                                              <br /><br />
                                                          </EditItemTemplate>
                                                      </obout:TemplateField>
                                                    <obout:DropDownListField DisplayField="Gender" DataField="GenderID" DataTextField="Gender" DataValueField="GenderID"  HeaderText="Gender:"  ControlStyle-Width="200" Required="false" ControlStyle-ForeColor="Red" DataSourceID="ObjectDataSourceGender" />
                                                        <obout:TemplateField>
                                                          <EditItemTemplate>
                                                              <br /><br />
                                                          </EditItemTemplate>
                                                      </obout:TemplateField>
                                                  <obout:BoundField DataField="Email" HeaderText="Email:" SortExpression="Email" ControlStyle-Width="200" Required="False" ControlStyle-ForeColor="Red" />
                                                  <obout:TemplateField HeaderText="Phone:">
                                                          <ItemTemplate>
                                                              <%# GetPhoneFormat(Eval("Phone"))%>
                                                          </ItemTemplate>
                                                         
                                                          <EditItemTemplate>
                                                           <obout:OboutTextBox ID="TextBoxPhoneedit" runat="server" text=' <%# Bind("Phone")%>'/>
                                                          
                                                          </EditItemTemplate>
                                                      </obout:TemplateField>
                                                 
                                                      <obout:TemplateField>
                                                          <EditItemTemplate>
                                                              <br /><br />
                                                          </EditItemTemplate>
                                                      </obout:TemplateField>
                                                   <obout:BoundField DataField="Address1" HeaderText="Address 1:" SortExpression="Address1" ControlStyle-Width="400" Required="False" ControlStyle-ForeColor="Red" />
                                                   <obout:BoundField DataField="Address2" HeaderText="Address 2:" SortExpression="Address1" ControlStyle-Width="300" Required="False" ControlStyle-ForeColor="Red" />
                                                   <obout:BoundField DataField="City" HeaderText="City:" SortExpression="City" ControlStyle-Width="200" Required="False" ControlStyle-ForeColor="Red" />
                                                   <obout:DropDownListField DisplayField="State" DataField="StateID" DataTextField="State" DataValueField="StateID"  HeaderText="State:"  ControlStyle-Width="200" Required="false" ControlStyle-ForeColor="Red" DataSourceID="ObjectDataSourceStates" />
                                                   <obout:BoundField DataField="PostalCode" HeaderText="PostalCode:" SortExpression="PostalCode" ControlStyle-Width="60" Required="False" ControlStyle-ForeColor="Red" />
                                                   <obout:DropDownListField DisplayField="Country" DataField="CountryID" DataTextField="Country" DataValueField="CountryID"  HeaderText="Country:"  ControlStyle-Width="200" Required="false" ControlStyle-ForeColor="Red" DataSourceID="ObjectDataSourceCountries" />
                                                   <obout:TemplateField>
                      
                       <HeaderTemplate>
                         Profile Picture:
                         </HeaderTemplate>
                          <ItemTemplate>
                              <asp:Image ID="ImageAquariumPicture" runat="server" BorderColor="Black" BorderStyle="Solid" BorderWidth="1" imageurl='<%# GetPictureFormat(Container.DataItem("PictureThumb")) %>'/>
                            
                              <asp:HiddenField ID="HiddenFieldPictureThumb" runat="server" value='<%# Eval("PictureThumb") %>' />
                              <asp:HiddenField ID="HiddenFieldPicture" runat="server" value='<%# Eval("Picture") %>' />
                         
                          </ItemTemplate>
                          <EditItemTemplate>
                        <asp:HiddenField ID="HiddenFieldPictureThumbedit" runat="server" value='<%# bind("PictureThumb") %>' />
                              <asp:HiddenField ID="HiddenFieldPictureedit" runat="server" value='<%# bind("Picture") %>' />
                              <asp:FileUpload ID="FileUploadEditPicture" runat="server" width="400" />
                          </EditItemTemplate>
                          
                      </obout:TemplateField>
                                              </Fields>
                                              </obout:SuperForm>
                                              
                                              <asp:ObjectDataSource ID="ObjectDataSourcePersonalInfo" runat="server" 
                                                  SelectMethod="GetPersonalInformation" TypeName="DAL" 
                                                  UpdateMethod="UpdatePersonalInformation">
                                                  <SelectParameters>
                                                      <asp:SessionParameter Name="UserAccountsID" SessionField="UserAccountsID" 
                                                          Type="Int32" />
                                                  </SelectParameters>
                                                  <UpdateParameters>
                                                      <asp:Parameter Name="UserAccountsID" Type="Int32" />
                                                      <asp:Parameter Name="NickName" Type="String" />
                                                      <asp:Parameter Name="FirstName" Type="String" />
                                                      <asp:Parameter Name="Lastname" Type="String" />
                                                      <asp:Parameter Name="GenderID" Type="Int32" />
                                                      <asp:Parameter Name="Email" Type="String" />
                                                      <asp:Parameter Name="Address1" Type="String" />
                                                      <asp:Parameter Name="Address2" Type="String" />
                                                      <asp:Parameter Name="city" Type="String" />
                                                      <asp:Parameter Name="StateID" Type="Int32" />
                                                      <asp:Parameter Name="PostalCode" Type="String" />
                                                      <asp:Parameter Name="CountryID" Type="Int32" />
                                                      <asp:Parameter Name="Phone" Type="String" />
                                                      <asp:Parameter Name="Picture" Type="String" />
                                                      <asp:Parameter Name="PictureThumb" Type="String" />
                                                  </UpdateParameters>
                                              </asp:ObjectDataSource>

          it's these two binds

          <asp:HiddenFiel d ID="HiddenField PictureThumbedi t" runat="server" value='<%# bind("PictureTh umb") %>' />
          <asp:HiddenFiel d ID="HiddenField Pictureedit" runat="server" value='<%# bind("Picture") %>' />

          lines 59 and 60
          the question is, what's the work around
          time to put on the thinking cap :)

          but I'd think the dataset would close after it fills the formview

          for some reason I need to bind those two so that I can do

          e.NewValues("Pi cture") = e.OldValues("Pi cture")

          e.NewValues("Pi ctureThumb") = e.OldValues("Pi ctureThumb")

          on the itemupdating

          Comment

          • vertigo262
            New Member
            • Jul 2007
            • 62

            #6
            My fix

            This is my fix

            Code:
            .aspx
                 <asp:HiddenField ID="HiddenFieldPictureThumbedit" runat="server" value='<%# eval("PictureThumb") %>' />
                                <asp:HiddenField ID="HiddenFieldPictureedit" runat="server" value='<%# eval("Picture") %>' />
                                <asp:FileUpload ID="FileUploadEditPicture" runat="server" width="400" />
                            </EditItemTemplate>
            
            
            .vb
            
              Dim PictureOld = CType(SuperFormAquariums.FindControl("HiddenFieldPictureEdit"), HiddenField).Value
                        Dim PictureThumbOld = CType(SuperFormAquariums.FindControl("HiddenFieldPictureThumbedit"), HiddenField).Value
                        'Response.Write("new:" & e.NewValues("Picture") & " " & e.NewValues("PictureThumb") & " OLD: " & e.OldValues("Picture") & " " & e.OldValues("PictureThumb"))
                        'Response.End()
            
                        e.NewValues("Picture") = PictureOld
            
                        e.NewValues("PictureThumb") = PictureThumbOld

            a little messy but works

            Comment

            • Frinavale
              Recognized Expert Expert
              • Oct 2006
              • 9749

              #7
              :) I'm glad you figured it out :)

              -Frinny

              Comment

              Working...