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

New Topic/Question
Reply



MultiQuote


|