Greetings,
I've created a message board with a file upload control, this should be optional.
So for example if people don't want to upload a picture with their message it should not return in an error.
c# code:
//Getting dbconnection from web.config connectionstring
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["dbgreatforestConnectionString"].ToString());
//Open the database connection
con.Open();
//Get Filename from fileupload control
string filename = Path.GetFileName(fileuploadimages.FileName);
//Save images into Images folder
fileuploadimages.SaveAs(Server.MapPath("Uploads/" + filename));
//Query to insert images path and name into database
SqlCommand cmd = new SqlCommand("Insert into msgs(msg, titel, naam, date, msgpic) values(@msg, @titel, @naam, @date, @msgpic)", con);
//Passing paramet ...
Go to the complete details ...