473,734 Members | 2,693 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

The process cannot access the file

62 New Member
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

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



Expand|Select|Wrap|Line Numbers
  1. insertion code
  2.  
  3.  
  4.  
  5.  
  6.             'upload picture
  7.             Dim PictureThumbpass
  8.             Dim PicturePass
  9.  
  10.             Dim fileLen As Integer
  11.             Dim myStream As System.IO.Stream
  12.             Dim ImgContentType As String
  13.             Dim UserName = NickName.Text
  14.  
  15.             Dim FileUploadPicture As FileUpload = FileUploadProfilePhoto
  16.  
  17.             'Response.Write(FileUploadPicture.HasFile)
  18.             'Response.End()
  19.  
  20.             If FileUploadPicture.HasFile Then
  21.                 'Create Dir
  22.                 Dim nd As New DirectoryInfo(Server.MapPath("\" + Application("SysUserDir") & "\" & UserName & "\Profile\Picture\"))
  23.                 If nd.Exists = False Then
  24.                     nd.Create()
  25.                 End If
  26.  
  27.                 'Create Dir
  28.                 Dim nd2 As New DirectoryInfo(Server.MapPath("\" + Application("SysUserDir") & "\" & UserName & "\Profile\PictureThumb\"))
  29.                 If nd2.Exists = False Then
  30.                     nd2.Create()
  31.                 End If
  32.  
  33.  
  34.  
  35.                 fileLen = FileUploadPicture.PostedFile.ContentLength
  36.                 ImgContentType = FileUploadPicture.PostedFile.ContentType
  37.  
  38.                 Dim Input(fileLen) As Byte
  39.                 myStream = FileUploadPicture.PostedFile.InputStream
  40.                 myStream.Read(Input, 0, fileLen)
  41.  
  42.                 'Response.Write(fileLen)
  43.                 'Response.End()
  44.  
  45.                 Dim Filename = FileUploadPicture.PostedFile.FileName
  46.  
  47.                 Dim Path1 = Server.MapPath("\" + Application("SysUserDir") & "\" & UserName & "\Profile\Picture\" & Filename)
  48.                 Dim DataPath1 = "/" & UserName & "/Profile/Picture/" & Filename
  49.  
  50.                 Dim Path2 = Server.MapPath("\" + Application("SysUserDir") & "\" & UserName & "\Profile\PictureThumb\" & Filename)
  51.                 Dim DataPath2 = "/" & UserName & "/Profile/PictureThumb/" & Filename
  52.  
  53.  
  54.                 If File.Exists(Path1) Or File.Exists(Path2) Then
  55.  
  56.                     'LabelPhotos.Text = "Photo has not been added to the system"
  57.                     'LabelConfirm.Text = "This photo image already exists in the system"
  58.                     LabelRegisterDone.Text = "<h2><font color=#FF0000>Registration Failure</font></h2><br>This File Already Exists<br><br>"
  59.                     MultiViewRegister.SetActiveView(ViewRegisterDone)
  60.                     e.Cancel = True
  61.  
  62.                 Else
  63.  
  64.  
  65.  
  66.                     'LabelConfirm.Text = ""
  67.                     Dim PictureInfoLarge = System.Drawing.Image.FromStream(myStream)
  68.  
  69.  
  70.  
  71.  
  72.                     'Get Picture To be Resized large
  73.                     Dim maxWidth1 As Integer = 800
  74.                     Dim maxHeight1 As Integer = 800
  75.                     Dim imgHeight1, imgWidth1 As Integer
  76.                     'Dim PictureInfo
  77.  
  78.  
  79.  
  80.                     imgHeight1 = PictureInfoLarge.Height
  81.                     imgWidth1 = PictureInfoLarge.Width
  82.  
  83.  
  84.                     ' Determine Scaling
  85.                     If imgWidth1 >= maxWidth1 Or imgHeight1 >= maxHeight1 Then
  86.                         'Determine what dimension is off by more
  87.                         Dim deltaWidth1 As Integer = imgWidth1 - maxWidth1
  88.                         Dim deltaHeight1 As Integer = imgHeight1 - maxHeight1
  89.                         Dim scaleFactor1 As Double
  90.  
  91.                         If deltaHeight1 > deltaWidth1 Then
  92.                             'Scale by the height
  93.                             scaleFactor1 = maxHeight1 / imgHeight1
  94.                         Else
  95.                             'Scale by the Width
  96.                             scaleFactor1 = maxWidth1 / imgWidth1
  97.                         End If
  98.  
  99.                         imgWidth1 *= scaleFactor1
  100.                         imgHeight1 *= scaleFactor1
  101.  
  102.                     Else
  103.  
  104.  
  105.                     End If
  106.  
  107.                     'Dim objThumbnail As System.Drawing.Image = PictureInfoLarge.GetThumbnailImage(imgWidth1, imgHeight1, Nothing, System.IntPtr.Zero)
  108.                     Dim objThumbnail As System.Drawing.Bitmap = PictureInfoLarge.GetThumbnailImage(imgWidth1, imgHeight1, Nothing, System.IntPtr.Zero)
  109.                     ' Dim graphicsImage As System.Drawing.Graphics = System.Drawing.Graphics.FromImage(objThumbnail)
  110.  
  111.                     '---------------supposed to fix -----------------------------------
  112.                     Dim graphicsImage As Graphics
  113.                     graphicsImage = Graphics.FromImage(objThumbnail)
  114.                     graphicsImage.SmoothingMode = Drawing.Drawing2D.SmoothingMode.HighQuality
  115.                     graphicsImage.InterpolationMode = Drawing2D.InterpolationMode.HighQualityBicubic
  116.                     graphicsImage.DrawImage(objThumbnail, 0, 0, imgWidth1, imgHeight1)
  117.                     '--------------------------------------------------------------------
  118.                     graphicsImage.Save()
  119.  
  120.                     objThumbnail.Save(Path1, Imaging.ImageFormat.Jpeg)
  121.  
  122.  
  123.                     graphicsImage.Dispose()
  124.  
  125.                     PicturePass = DataPath1
  126.                     'e.Values("Picture") = DataPath1
  127.  
  128.                     PictureInfoLarge = Nothing
  129.                     objThumbnail = Nothing
  130.  
  131.  
  132.                     Dim PictureInfoSmall = System.Drawing.Image.FromStream(myStream)
  133.  
  134.  
  135.                     'Get Picture To be Resized small
  136.                     Dim maxWidth2 = 150
  137.                     Dim maxHeight2 = 150
  138.                     'imgHeight, imgWidth As Integer
  139.                     'Dim PictureInfo
  140.  
  141.  
  142.  
  143.                     Dim imgHeight2 = PictureInfoSmall.Height
  144.                     Dim imgWidth2 = PictureInfoSmall.Width
  145.  
  146.                     ' Determine Scaling
  147.                     If imgWidth2 >= maxWidth2 Or imgHeight2 >= maxHeight2 Then
  148.                         'Determine what dimension is off by more
  149.                         ' Dim deltaWidth As Integer = imgWidth - maxWidth
  150.                         'Dim deltaHeight As Integer = imgHeight - maxHeight
  151.                         ' Dim scaleFactor As Double
  152.                         Dim deltaWidth2 As Integer = imgWidth2 - maxWidth2
  153.                         Dim deltaHeight2 As Integer = imgHeight2 - maxHeight2
  154.                         Dim scaleFactor2 As Double
  155.  
  156.                         If deltaHeight2 > deltaWidth2 Then
  157.                             'Scale by the height
  158.                             scaleFactor2 = maxHeight2 / imgHeight2
  159.                         Else
  160.                             'Scale by the Width
  161.                             scaleFactor2 = maxWidth2 / imgWidth2
  162.                         End If
  163.  
  164.                         imgWidth2 *= scaleFactor2
  165.                         imgHeight2 *= scaleFactor2
  166.  
  167.                     Else
  168.  
  169.                     End If
  170.  
  171.  
  172.                     Dim objThumbnail2 As System.Drawing.Bitmap = PictureInfoSmall.GetThumbnailImage(imgWidth2, imgHeight2, Nothing, System.IntPtr.Zero)
  173.  
  174.                     '---------------supposed to fix -----------------------------------
  175.                     Dim graphicsImage2 As Graphics
  176.                     graphicsImage2 = Graphics.FromImage(objThumbnail2)
  177.                     graphicsImage2.SmoothingMode = Drawing.Drawing2D.SmoothingMode.HighQuality
  178.                     graphicsImage2.InterpolationMode = Drawing2D.InterpolationMode.HighQualityBicubic
  179.                     graphicsImage2.DrawImage(objThumbnail2, 0, 0, imgWidth2, imgHeight2)
  180.                     '--------------------------------------------------------------------
  181.                     graphicsImage2.Save()
  182.  
  183.                     objThumbnail2.Save(Path2, Imaging.ImageFormat.Jpeg)
  184.  
  185.                     graphicsImage2.Dispose()
  186.  
  187.                     PictureThumbpass = DataPath2
  188.                     'e.Values("PictureThumb") = DataPath2
  189.  
  190.  
  191.                     myStream.Close()
  192.                     myStream.Dispose()
  193.  
  194.                     PictureInfoSmall = Nothing
  195.                     objThumbnail2 = Nothing
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202.  
  203.                 End If
  204.  
  205.  
  206.             ElseIf Not FileUploadPicture.HasFile Then
  207.  
  208.  
  209.             End If
  210.  
  211.  
  212.  
  213. Update Code, almost the same
  214.  
  215.  
  216.  
  217.  
  218.  
  219.  
  220.  
  221.  
  222.  
  223.  
  224.   Protected Sub SuperFormPersonalInformation_ItemUpdating(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DetailsViewUpdateEventArgs) Handles SuperFormPersonalInformation.ItemUpdating
  225.  
  226.  
  227.  
  228.         Dim fileLen As Integer
  229.         Dim myStream As System.IO.Stream
  230.         Dim ImgContentType As String
  231.         Dim UserName = Dal.GetNickName(Dal.GetUserID)
  232.  
  233.         Dim FileUploadPicture As FileUpload = SuperFormPersonalInformation.FindControl("FileUploadEditPicture")
  234.  
  235.         'Response.Write(FileUploadPicture.HasFile)
  236.         'Response.End()
  237.  
  238.         If FileUploadPicture.HasFile Then
  239.             'Create Dir
  240.             Dim nd As New DirectoryInfo(Server.MapPath("\" + Application("SysUserDir") & "\" & UserName & "\Profile\Picture\"))
  241.             If nd.Exists = False Then
  242.                 nd.Create()
  243.             End If
  244.  
  245.             'Create Dir
  246.             Dim nd2 As New DirectoryInfo(Server.MapPath("\" + Application("SysUserDir") & "\" & UserName & "\Profile\PictureThumb\"))
  247.             If nd2.Exists = False Then
  248.                 nd2.Create()
  249.             End If
  250.  
  251.  
  252.  
  253.             fileLen = FileUploadPicture.PostedFile.ContentLength
  254.             ImgContentType = FileUploadPicture.PostedFile.ContentType
  255.  
  256.             Dim Input(fileLen) As Byte
  257.             myStream = FileUploadPicture.PostedFile.InputStream
  258.             myStream.Read(Input, 0, fileLen)
  259.  
  260.             'Response.Write(fileLen)
  261.             'Response.End()
  262.  
  263.             Dim Filename = FileUploadPicture.PostedFile.FileName
  264.  
  265.             Dim Path1 = Server.MapPath("\" + Application("SysUserDir") & "\" & UserName & "\Profile\Picture\" & Filename)
  266.             Dim DataPath1 = "/" & UserName & "/Profile/Picture/" & Filename
  267.             Dim OldPath1 = Server.MapPath("/" & Application("SysUserDir") & "/" & e.OldValues("Picture"))
  268.  
  269.             Dim Path2 = Server.MapPath("\" + Application("SysUserDir") & "\" & UserName & "\Profile\PictureThumb\" & Filename)
  270.             Dim DataPath2 = "/" & UserName & "/Profile/PictureThumb/" & Filename
  271.             Dim OldPath2 = Server.MapPath("/" & Application("SysUserDir") & "/" & e.OldValues("PictureThumb"))
  272.  
  273.  
  274.             'Response.Write(DataPath1 & " " & DataPath2)
  275.             'Response.End()
  276.             'delete old image
  277.  
  278.             'delete old files
  279.             If FileUploadPicture.HasFile Then
  280.                 Dim fd1 As New FileInfo(OldPath1)
  281.                 If fd1.Exists = True Then
  282.                     fd1.Delete()
  283.                 End If
  284.             End If
  285.  
  286.             If FileUploadPicture.HasFile Then
  287.                 Dim fd2 As New FileInfo(OldPath2)
  288.                 If fd2.Exists = True Then
  289.                     fd2.Delete()
  290.                 End If
  291.             End If
  292.  
  293.  
  294.  
  295.  
  296.  
  297.             If File.Exists(Path1) Or File.Exists(Path2) Then
  298.  
  299.                 'LabelPhotos.Text = "Photo has not been added to the system"
  300.                 LabelConfirmPersonalInfo.Text = "This photo image already exists in the system"
  301.                 e.Cancel = True
  302.  
  303.             Else
  304.  
  305.  
  306.  
  307.                 LabelConfirmPersonalInfo.Text = ""
  308.                 Dim PictureInfoLarge = System.Drawing.Image.FromStream(myStream)
  309.  
  310.  
  311.  
  312.  
  313.                 'Get Picture To be Resized large
  314.                 Dim maxWidth1 As Integer = 800
  315.                 Dim maxHeight1 As Integer = 800
  316.                 Dim imgHeight1, imgWidth1 As Integer
  317.                 'Dim PictureInfo
  318.  
  319.  
  320.  
  321.                 imgHeight1 = PictureInfoLarge.Height
  322.                 imgWidth1 = PictureInfoLarge.Width
  323.  
  324.  
  325.                 ' Determine Scaling
  326.                 If imgWidth1 >= maxWidth1 Or imgHeight1 >= maxHeight1 Then
  327.                     'Determine what dimension is off by more
  328.                     Dim deltaWidth1 As Integer = imgWidth1 - maxWidth1
  329.                     Dim deltaHeight1 As Integer = imgHeight1 - maxHeight1
  330.                     Dim scaleFactor1 As Double
  331.  
  332.                     If deltaHeight1 > deltaWidth1 Then
  333.                         'Scale by the height
  334.                         scaleFactor1 = maxHeight1 / imgHeight1
  335.                     Else
  336.                         'Scale by the Width
  337.                         scaleFactor1 = maxWidth1 / imgWidth1
  338.                     End If
  339.  
  340.                     imgWidth1 *= scaleFactor1
  341.                     imgHeight1 *= scaleFactor1
  342.  
  343.                 Else
  344.  
  345.  
  346.                 End If
  347.  
  348.                 'Dim objThumbnail As System.Drawing.Image = PictureInfoLarge.GetThumbnailImage(imgWidth1, imgHeight1, Nothing, System.IntPtr.Zero)
  349.                 Dim objThumbnail As System.Drawing.Bitmap = PictureInfoLarge.GetThumbnailImage(imgWidth1, imgHeight1, Nothing, System.IntPtr.Zero)
  350.                 ' Dim graphicsImage As System.Drawing.Graphics = System.Drawing.Graphics.FromImage(objThumbnail)
  351.  
  352.                 '---------------supposed to fix -----------------------------------
  353.                 Dim graphicsImage As Graphics
  354.                 graphicsImage = Graphics.FromImage(objThumbnail)
  355.                 graphicsImage.SmoothingMode = Drawing.Drawing2D.SmoothingMode.HighQuality
  356.                 graphicsImage.InterpolationMode = Drawing2D.InterpolationMode.HighQualityBicubic
  357.                 graphicsImage.DrawImage(objThumbnail, 0, 0, imgWidth1, imgHeight1)
  358.                 '--------------------------------------------------------------------
  359.                 graphicsImage.Save()
  360.  
  361.                 objThumbnail.Save(Path1, Imaging.ImageFormat.Jpeg)
  362.  
  363.                 'Response.Write(objThumbnail.PixelFormat & "<BR><BR>")
  364.                 'Response.Write(objThumbnail.PhysicalDimension)
  365.                 'Response.Write(objThumbnail.Size)
  366.  
  367.                 'Response.End()
  368.  
  369.  
  370.                 graphicsImage.Dispose()
  371.  
  372.                 e.NewValues("Picture") = DataPath1
  373.  
  374.                 PictureInfoLarge = Nothing
  375.                 objThumbnail = Nothing
  376.  
  377.  
  378.                 Dim PictureInfoSmall = System.Drawing.Image.FromStream(myStream)
  379.  
  380.  
  381.                 'Get Picture To be Resized small
  382.                 Dim maxWidth2 = 150
  383.                 Dim maxHeight2 = 150
  384.                 'imgHeight, imgWidth As Integer
  385.                 'Dim PictureInfo
  386.  
  387.  
  388.  
  389.                 Dim imgHeight2 = PictureInfoSmall.Height
  390.                 Dim imgWidth2 = PictureInfoSmall.Width
  391.  
  392.                 ' Determine Scaling
  393.                 If imgWidth2 >= maxWidth2 Or imgHeight2 >= maxHeight2 Then
  394.                     'Determine what dimension is off by more
  395.                     ' Dim deltaWidth As Integer = imgWidth - maxWidth
  396.                     'Dim deltaHeight As Integer = imgHeight - maxHeight
  397.                     ' Dim scaleFactor As Double
  398.                     Dim deltaWidth2 As Integer = imgWidth2 - maxWidth2
  399.                     Dim deltaHeight2 As Integer = imgHeight2 - maxHeight2
  400.                     Dim scaleFactor2 As Double
  401.  
  402.                     If deltaHeight2 > deltaWidth2 Then
  403.                         'Scale by the height
  404.                         scaleFactor2 = maxHeight2 / imgHeight2
  405.                     Else
  406.                         'Scale by the Width
  407.                         scaleFactor2 = maxWidth2 / imgWidth2
  408.                     End If
  409.  
  410.                     imgWidth2 *= scaleFactor2
  411.                     imgHeight2 *= scaleFactor2
  412.  
  413.                 Else
  414.  
  415.                 End If
  416.  
  417.  
  418.                 Dim objThumbnail2 As System.Drawing.Bitmap = PictureInfoSmall.GetThumbnailImage(imgWidth2, imgHeight2, Nothing, System.IntPtr.Zero)
  419.  
  420.                 '---------------supposed to fix -----------------------------------
  421.                 Dim graphicsImage2 As Graphics
  422.                 graphicsImage2 = Graphics.FromImage(objThumbnail2)
  423.                 graphicsImage2.SmoothingMode = Drawing.Drawing2D.SmoothingMode.HighQuality
  424.                 graphicsImage2.InterpolationMode = Drawing2D.InterpolationMode.HighQualityBicubic
  425.                 graphicsImage2.DrawImage(objThumbnail2, 0, 0, imgWidth2, imgHeight2)
  426.                 '--------------------------------------------------------------------
  427.                 graphicsImage2.Save()
  428.  
  429.                 objThumbnail2.Save(Path2, Imaging.ImageFormat.Jpeg)
  430.  
  431.                 graphicsImage2.Dispose()
  432.  
  433.  
  434.                 e.NewValues("PictureThumb") = DataPath2
  435.  
  436.  
  437.                 myStream.Close()
  438.                 myStream.Dispose()
  439.  
  440.                 PictureInfoSmall = Nothing
  441.                 objThumbnail2 = Nothing
  442.  
  443.  
  444.  
  445.  
  446.  
  447.  
  448.  
  449.             End If
  450.  
  451.  
  452.         ElseIf Not FileUploadPicture.HasFile Then
  453.  
  454.             'Dim PictureOld = CType(SuperFormAquariums.FindControl("HiddenFieldPictureEdit"), HiddenField).Value
  455.             'Dim PictureThumbOld = CType(SuperFormAquariums.FindControl("HiddenFieldPictureThumbedit"), HiddenField).Value
  456.             'Response.Write("new:" & e.NewValues("Picture") & " " & e.NewValues("PictureThumb") & " OLD: " & e.OldValues("Picture") & " " & e.OldValues("PictureThumb"))
  457.             'Response.End()
  458.  
  459.             e.NewValues("Picture") = e.OldValues("Picture")
  460.  
  461.             e.NewValues("PictureThumb") = e.OldValues("PictureThumb")
  462.  
  463.         End If
  464.  
  465.  
  466.     End Sub
  467.  

any help would be appreciated
Oct 24 '10 #1
6 4631
Frinavale
9,735 Recognized Expert Moderator Expert
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
Oct 25 '10 #2
vertigo262
62 New Member
Hi Frinny ,

I only have one stream, and I'm closing it at the end. unless I'm missing something
Oct 25 '10 #3
vertigo262
62 New Member
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

http://www.reefjunkies.org/AccountSe...nalInformation

login: bill
password: bill
Oct 25 '10 #4
vertigo262
62 New Member
OK, found where the glitch is

Expand|Select|Wrap|Line Numbers
  1.  <obout:SuperForm ID="SuperFormPersonalInformation" runat="server" AutoGenerateEditButton="True" 
  2.                                     DataKeyNames="UserAccountsID" AutoGenerateRows="False" Width="100%"  
  3.                                         HorizontalAlign="Center" DataSourceID="ObjectDataSourcePersonalInfo" 
  4.                                         BorderColor="#AEADAD" BorderStyle="Solid" BorderWidth="1px" 
  5.                                         HeaderStyle-BorderColor="#AEADAD" HeaderStyle-BorderStyle="Solid" 
  6.                                         HeaderStyle-BorderWidth="1" AllowDataKeysInsert="False" GridLines="Both">
  7.  
  8.                                     <Fields>
  9.                                         <obout:BoundField DataField="NickName" HeaderText="NickName:" SortExpression="NickName" ControlStyle-Width="200" Required="False" ControlStyle-ForeColor="Red" />
  10.                                         <obout:BoundField DataField="FirstName" HeaderText="First Name:" SortExpression="FirstName" ControlStyle-Width="300" Required="False" ControlStyle-ForeColor="Red" />
  11.                                         <obout:BoundField DataField="LastName" HeaderText="Last Name:" SortExpression="LastName" ControlStyle-Width="300" Required="False" ControlStyle-ForeColor="Red" />
  12.                                             <obout:TemplateField>
  13.                                                 <EditItemTemplate>
  14.                                                     <br /><br />
  15.                                                 </EditItemTemplate>
  16.                                             </obout:TemplateField>
  17.                                           <obout:DropDownListField DisplayField="Gender" DataField="GenderID" DataTextField="Gender" DataValueField="GenderID"  HeaderText="Gender:"  ControlStyle-Width="200" Required="false" ControlStyle-ForeColor="Red" DataSourceID="ObjectDataSourceGender" />
  18.                                               <obout:TemplateField>
  19.                                                 <EditItemTemplate>
  20.                                                     <br /><br />
  21.                                                 </EditItemTemplate>
  22.                                             </obout:TemplateField>
  23.                                         <obout:BoundField DataField="Email" HeaderText="Email:" SortExpression="Email" ControlStyle-Width="200" Required="False" ControlStyle-ForeColor="Red" />
  24.                                         <obout:TemplateField HeaderText="Phone:">
  25.                                                 <ItemTemplate>
  26.                                                     <%# GetPhoneFormat(Eval("Phone"))%>
  27.                                                 </ItemTemplate>
  28.  
  29.                                                 <EditItemTemplate>
  30.                                                  <obout:OboutTextBox ID="TextBoxPhoneedit" runat="server" text=' <%# Bind("Phone")%>'/>
  31.  
  32.                                                 </EditItemTemplate>
  33.                                             </obout:TemplateField>
  34.  
  35.                                             <obout:TemplateField>
  36.                                                 <EditItemTemplate>
  37.                                                     <br /><br />
  38.                                                 </EditItemTemplate>
  39.                                             </obout:TemplateField>
  40.                                          <obout:BoundField DataField="Address1" HeaderText="Address 1:" SortExpression="Address1" ControlStyle-Width="400" Required="False" ControlStyle-ForeColor="Red" />
  41.                                          <obout:BoundField DataField="Address2" HeaderText="Address 2:" SortExpression="Address1" ControlStyle-Width="300" Required="False" ControlStyle-ForeColor="Red" />
  42.                                          <obout:BoundField DataField="City" HeaderText="City:" SortExpression="City" ControlStyle-Width="200" Required="False" ControlStyle-ForeColor="Red" />
  43.                                          <obout:DropDownListField DisplayField="State" DataField="StateID" DataTextField="State" DataValueField="StateID"  HeaderText="State:"  ControlStyle-Width="200" Required="false" ControlStyle-ForeColor="Red" DataSourceID="ObjectDataSourceStates" />
  44.                                          <obout:BoundField DataField="PostalCode" HeaderText="PostalCode:" SortExpression="PostalCode" ControlStyle-Width="60" Required="False" ControlStyle-ForeColor="Red" />
  45.                                          <obout:DropDownListField DisplayField="Country" DataField="CountryID" DataTextField="Country" DataValueField="CountryID"  HeaderText="Country:"  ControlStyle-Width="200" Required="false" ControlStyle-ForeColor="Red" DataSourceID="ObjectDataSourceCountries" />
  46.                                          <obout:TemplateField>
  47.  
  48.              <HeaderTemplate>
  49.                Profile Picture:
  50.                </HeaderTemplate>
  51.                 <ItemTemplate>
  52.                     <asp:Image ID="ImageAquariumPicture" runat="server" BorderColor="Black" BorderStyle="Solid" BorderWidth="1" imageurl='<%# GetPictureFormat(Container.DataItem("PictureThumb")) %>'/>
  53.  
  54.                     <asp:HiddenField ID="HiddenFieldPictureThumb" runat="server" value='<%# Eval("PictureThumb") %>' />
  55.                     <asp:HiddenField ID="HiddenFieldPicture" runat="server" value='<%# Eval("Picture") %>' />
  56.  
  57.                 </ItemTemplate>
  58.                 <EditItemTemplate>
  59.               <asp:HiddenField ID="HiddenFieldPictureThumbedit" runat="server" value='<%# bind("PictureThumb") %>' />
  60.                     <asp:HiddenField ID="HiddenFieldPictureedit" runat="server" value='<%# bind("Picture") %>' />
  61.                     <asp:FileUpload ID="FileUploadEditPicture" runat="server" width="400" />
  62.                 </EditItemTemplate>
  63.  
  64.             </obout:TemplateField>
  65.                                     </Fields>
  66.                                     </obout:SuperForm>
  67.  
  68.                                     <asp:ObjectDataSource ID="ObjectDataSourcePersonalInfo" runat="server" 
  69.                                         SelectMethod="GetPersonalInformation" TypeName="DAL" 
  70.                                         UpdateMethod="UpdatePersonalInformation">
  71.                                         <SelectParameters>
  72.                                             <asp:SessionParameter Name="UserAccountsID" SessionField="UserAccountsID" 
  73.                                                 Type="Int32" />
  74.                                         </SelectParameters>
  75.                                         <UpdateParameters>
  76.                                             <asp:Parameter Name="UserAccountsID" Type="Int32" />
  77.                                             <asp:Parameter Name="NickName" Type="String" />
  78.                                             <asp:Parameter Name="FirstName" Type="String" />
  79.                                             <asp:Parameter Name="Lastname" Type="String" />
  80.                                             <asp:Parameter Name="GenderID" Type="Int32" />
  81.                                             <asp:Parameter Name="Email" Type="String" />
  82.                                             <asp:Parameter Name="Address1" Type="String" />
  83.                                             <asp:Parameter Name="Address2" Type="String" />
  84.                                             <asp:Parameter Name="city" Type="String" />
  85.                                             <asp:Parameter Name="StateID" Type="Int32" />
  86.                                             <asp:Parameter Name="PostalCode" Type="String" />
  87.                                             <asp:Parameter Name="CountryID" Type="Int32" />
  88.                                             <asp:Parameter Name="Phone" Type="String" />
  89.                                             <asp:Parameter Name="Picture" Type="String" />
  90.                                             <asp:Parameter Name="PictureThumb" Type="String" />
  91.                                         </UpdateParameters>
  92.                                     </asp:ObjectDataSource>
  93.  

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
Oct 26 '10 #5
vertigo262
62 New Member
This is my fix

Expand|Select|Wrap|Line Numbers
  1. .aspx
  2.      <asp:HiddenField ID="HiddenFieldPictureThumbedit" runat="server" value='<%# eval("PictureThumb") %>' />
  3.                     <asp:HiddenField ID="HiddenFieldPictureedit" runat="server" value='<%# eval("Picture") %>' />
  4.                     <asp:FileUpload ID="FileUploadEditPicture" runat="server" width="400" />
  5.                 </EditItemTemplate>
  6.  
  7.  
  8. .vb
  9.  
  10.   Dim PictureOld = CType(SuperFormAquariums.FindControl("HiddenFieldPictureEdit"), HiddenField).Value
  11.             Dim PictureThumbOld = CType(SuperFormAquariums.FindControl("HiddenFieldPictureThumbedit"), HiddenField).Value
  12.             'Response.Write("new:" & e.NewValues("Picture") & " " & e.NewValues("PictureThumb") & " OLD: " & e.OldValues("Picture") & " " & e.OldValues("PictureThumb"))
  13.             'Response.End()
  14.  
  15.             e.NewValues("Picture") = PictureOld
  16.  
  17.             e.NewValues("PictureThumb") = PictureThumbOld
  18.  
  19.  
  20.  
  21.  

a little messy but works
Oct 26 '10 #6
Frinavale
9,735 Recognized Expert Moderator Expert
:) I'm glad you figured it out :)

-Frinny
Oct 26 '10 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

9
715
by: Paul | last post by:
Hi, VB.NET is saying the file I am creating is in use by another process and won't complete its task of moving the file to the specified destination folder. Here is my code (the main bit anyway).... Private Sub LogChange(ByVal source As Object, ByVal e As System.IO.FileSystemEventArgs) If e.ChangeType = WatcherChangeTypes.Created Then
5
2426
by: Mike Dole | last post by:
When I am updating a picturebox with an image (extracted) from an access database I keep getting a "The process cannot access the file "c:\foto1.jpg because it is being used by another process" this only happens the second time I run it, the first time it works out fine.. I've tried things like MyPicBox.dispose MyPicBox = nothing etc,etc
1
1251
by: Jurgen Oerlemans | last post by:
Hello, I perform several actions on a file: * copy "xxx.txt" from directory 1 to "file.txt" directory 2 * process "file.txt" which is in directory 2 * delete the file in directory 1 .... and start over again. Sometimes I get the error: "The process cannot access the file "path\file.txt" because it is being used by another process"
0
2960
nightangel
by: nightangel | last post by:
Hi dude,what i was done in my application is uploading a image file to my server using FTP, it work great when pushing a file into the server path using FTP. The problem i met now is i need to do a resuming for the file uploading if the client connection or server connection is down. E.g: Sunset.jpg (500KB) when i upload until half of it, (332KB in the server) and unplug my connection, it will looping and try to connect to the server, after...
0
8946
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9449
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9236
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9182
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6735
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6031
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4809
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2724
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2180
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.