Try this, I hope it may help you
protected void btnUpload_Click(object sender, EventArgs e)
{
string filename;
string ImageFileName;
if (pics.HasFile)
{
filename = System.IO.Path.GetFileName(pics.FileName);
pics.SaveAs(Server.MapPath("/Galery/") + filename);
ImageFileName = "/Galery/" + filename;
}
SqlConnection Conn = new SqlConnection(System.Configuration.ConfigurationManager.AppSettings["myConnectionString"]);
SqlCommand CatCmd = Conn.CreateCommand();
Conn.Open();
try
{
CatCmd.CommandText = "insert into PhotoGaleryImage(CatagoryId,Path,UserId) values('CatagoryID','ImageFileName','userId')";
CatCmd.ExecuteNonQuery();
}
catch (Exception) { }
finally
{
if (Conn != null && Conn.State == ConnectionState.Open)
{
Conn.Close();
Conn.Dispose();
}
}
}
*Galary should be one of your folder included in the solution
*pics is the Fileupload control
Keep smiling :):):) happy coding:)