Yo people, I got a page where you can add the name of a bird a discription and 5 photos, when you press the save button it will upload the selected photos and it wil save the url and name into the database but now I have the following error: ***************************************************************************
Object reference not set to an instance of an object. 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.NullReferenceException: Object reference not set to an instance of an object. Source Error: Line 30: // String targetFile5 = "D://dekleurkwekers.nl//database//fotos//fotogallerie//" + fName + 5 + ".PNG"; Line 31: Line 32: bestand1.PostedFile.SaveAs("c:\\inetpub\\wwwroot\\Vogelvereniging\\database\\fotos\\fotogallerie\\"
+ fName + 1 + ".PNG"); *************************************************************************** here is my source: <script runat="server"> public void Page_Load(Object sender,EventArgs e) { if(Session["Admin"]==null) Response.Redirect("../../Inloggen.aspx");
} public void Button1_Click(Object sender, EventArgs e) { string strNaam; strNaam = vogel.Text + "-foto"; string strFileName = strNaam; string fName = Path.GetFileName(strFileName); bestand1.PostedFile.SaveAs("c:\\inetpub\\wwwroot\\Vogelvereniging\\database\\fotos\\fotogallerie\\"
+ fName + 1 + ".PNG"); bestand2.PostedFile.SaveAs("c:\\inetpub\\wwwroot\\Vogelvereniging\\database\\fotos\\fotogallerie\\" + fName + 2 + ".PNG"); bestand3.PostedFile.SaveAs("c:\\inetpub\\wwwroot\\Vogelvereniging\\database\\fotos\\fotogallerie\\" + fName +
3 + ".PNG"); bestand4.PostedFile.SaveAs("c:\\inetpub\\wwwroot\\Vogelvereniging\\database\\fotos\\fotogallerie\\" + fName + 4 + ".PNG"); bestand5.PostedFile.SaveAs("c:\\inetpub\\wwwroot\\Vogelvereniging\\database\\fotos\\fotogallerie\\" + fName + 5 + ".PNG");
string locatie1 = ""; string locatie2 = ""; string locatie3 = ""; string locatie4 = "";
string locatie5 = ""; try { OleDbConnection db_locatie = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Server.MapPath(".") + ConfigurationSettings.AppSettings["Database_Locatie"]);
OleDbCommand toevoegen = new OleDbCommand("INSERT INTO fotogallerie (vogel, beschrijving, foto1, foto2, foto3, foto4, foto5) VALUES ('" + vogel.Text + "','" + beschrijving.Text + "','" + locatie1 + "','" + locatie2 + "','" + locatie3 + "','" + locatie4 + "','"
+ locatie5 + "')", db_locatie); db_locatie.Open(); toevoegen.ExecuteNonQuery(); db_locatie.Close() ; Message.Text = "De gegevens zijn toegevoegd"; } catch (OleDbException ex) { error.Text = "Er ging iets fout bij het connecten met de database, probeer het
a.u.b. opnieuw."; } } </script>
AthlonPower
Member
235 Points
47 Posts
Upload images and save url in acces db (C#)
Aug 23, 2003 01:34 PM|LINK
<form runat="server">
</form> I hope its clear what i mean, tnx in advanced
AthlonPower
Member
235 Points
47 Posts
Re: Upload images and save url in acces db (C#)
Aug 28, 2003 04:58 PM|LINK