0 Replies - 2945 Views - Last Post: 07 August 2012 - 12:00 PM Rate Topic: -----

#1 romil797  Icon User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 50
  • Joined: 24-April 11

Unrecognized Database format possible causes

Posted 07 August 2012 - 12:00 PM

I have a website for a painter where the painter uploads a picture. The picture name is added to a mdb (access) database table, the picture is added to the end of a table called galleries, and the file is uploaded. It is also then resized to a small image.

Sometimes, not always, I get Unrecognized Database Format error after running this. Anyone think of any possible causes and what I can do about them without changing the main structure of the program?

Thanks for your help!

 If (FileUpload1.FileName.Substring(FileUpload1.FileName.Length - 4) = ".jpg" And IsNumeric(w.Text) And IsNumeric(h.Text) And IsNothing(title.Text) = False) Then
                conns = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & Server.MapPath("art.mdb")
                redir = New Recordset
                strSQL = "SELECT COUNT(Title) AS r FROM Paintings WHERE Title='" +title.Text+"'"
                redir.Open(strSQL, conns)
                If Convert.ToInt16(redir.Fields.Item("r").Value) > 0 Then
                    redir.Close()
                    Response.Redirect("editgallery.aspx?GID=" + idGallery + "&er=True")
                End If
                FileUpload1.SaveAs(Server.MapPath("~/") & "images\Large\l_" & title.Text.Replace(" ", "").ToLower() & ".jpg")
                FileUpload1.Dispose() //uploaded img
                Dim myCallback As New System.Drawing.Image.GetThumbnailImageAbort(AddressOf ThumbnailCallback)
                Dim myBitmap As System.Drawing.Bitmap
                myBitmap = New System.Drawing.Bitmap(Server.MapPath("images/Large/l_" & title.Text.Replace(" ", "").ToLower() & ".jpg"))
                Dim myThumbnail As Drawing.Image = myBitmap.GetThumbnailImage(165, (165 / myBitmap.Width) * myBitmap.Height, myCallback, IntPtr.Zero) //create a thumbnail
                myThumbnail.Save(Server.MapPath("images\Small\s_" & title.Text.Replace(" ", "").ToLower() & ".jpg"), System.Drawing.Imaging.ImageFormat.Jpeg)
                myThumbnail.Dispose()
                myBitmap.Dispose()
                strSQL = "INSERT INTO Paintings (Title, HeightInches, WidthInches, ImageBaseName) VALUES (""" & title.Text & """, " & h.Text & ", " & w.Text & ", """ & title.Text.Replace(" ", "").ToLower() & """)"
                Dim conn As OleDbConnection = Nothing
                conn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & Server.MapPath("art.mdb"))
                conn.Open()
                Dim cmd As New OleDbCommand(strSQL, conn)
                cmd.ExecuteNonQuery()
                conn.Close() //added to paintings table
                conn = New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & Server.MapPath("art.mdb"))
                conn.Open()
                maxas = New Recordset
                strSQL = "SELECT MAX(PaintingID) AS maxot FROM Paintings" //new painting is the last one
                maxas.Open(strSQL, conns)
                maxs = New Recordset
                strSQL = "SELECT MAX(Ordering) AS maxot FROM GalleryEntries WHERE GalleryID=" & idGallery
                maxs.Open(strSQL, conns)
                strSQL = "INSERT INTO GalleryEntries VALUES (" & idGallery & ", " & maxas.Fields.Item("maxot").Value & ", " & maxs.Fields.Item("maxot").Value & "+1)" //add to galleryentries table
                cmd = New OleDbCommand(strSQL, conn)
                cmd.ExecuteNonQuery()
                conn.Close()
                maxs.Close()
                maxas.Close()
                Response.Redirect("editgallery.aspx?GID=" + idGallery)
            End If


This post has been edited by romil797: 07 August 2012 - 05:54 PM


Is This A Good Question/Topic? 0
  • +

Page 1 of 1