Click here to Skip to main content
15,897,334 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
code in business layer :
C#
FilesEntity files = new FilesEntity();
        public void SaveFileName(FilesEntity filentity)
        {
            string cs = ConfigurationManager.ConnectionStrings["DBCS"].ConnectionString;
            using (SqlConnection con = new SqlConnection(cs))
            {
                SqlCommand cmd = new SqlCommand("spnotaryfiles", con);
                cmd.Parameters.AddWithValue("@Filename", files.filename);
                cmd.CommandType = CommandType.StoredProcedure;
                con.Open();
                cmd.ExecuteNonQuery();
            }
        }


Code in COntroller :
C#
[HttpPost]
        public ActionResult Index()
        {
            
            {
                FilesEntity entity = new FilesEntity();
                string path = Path.Combine(Server.MapPath("~/Images"),
                Path.GetFileName(entity.filename));
                
                DataAccess da = new DataAccess();
                da.SaveFileName(entity);
            }
            
            return View();
        }


COde in view
HTML
@using (Html.BeginForm("Index", "File", FormMethod.Post, new { enctype = "multipart/form-data" }))
{

    <input type="file" name="fileUpload" /><br />
    <input type="submit" name="Submit" id="Submit" value="Upload" />
  
}


please help me to save the file name in database. thanks in advance
Posted
Updated 1-Mar-15 20:22pm
v3

1 solution

Try out with this business logic:
C#
FilesEntity files = new FilesEntity();
public void SaveFileName(FilesEntity filentity)
{
    files = filentity;
    string cs = ConfigurationManager.ConnectionStrings["DBCS"].ConnectionString;
    using (SqlConnection con = new SqlConnection(cs))
    {
    SqlCommand cmd = new SqlCommand("spnotaryfiles", con);
    cmd.Parameters.AddWithValue("@Filename", files.filename);
    cmd.CommandType = CommandType.StoredProcedure;
    con.Open();
    cmd.ExecuteNonQuery();
    }
}


-KR
 
Share this answer
 
Comments
raxhemanth 2-Mar-15 2:32am    
thanks for responding let me try.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900