how should i specify the path in the "cmd.parameters.addwithvalue" field?

Posted by Shreesh under ASP.NET on 10/14/2011 | Points: 10 | Views : 1334 | Status : [Member] | Replies : 1
hello, i'm trying to save the path of the file i have uploaded using "FileUpload" control in the database. but i couldn't till now .how should i specify the path in the "cmd.parameters.addwithvalue" field?
hoping you can help,thanks in advance.

cmd = new SqlCommand("db_vid", con);
cmd.Connection = con;
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@video",FileUpload1.HasFile.ToString() );
FileUpload1.SaveAs(Server.MapPath(".") + FileUpload1.FileName);


Posted by: Ndebata on: 10/17/2011 [Member] Starter | Points: 25

First store the path to a string then use this to save the file and insert the same to database
string _fpath=Server.MapPath(".") + FileUpload1.FileName;

//Here @video should be the parameter name in your query/ stored procedure
cmd.Parameters.AddWithValue("@video",_fpath );

Ideally you could have created another folder for keeping your videos instead of directly keeping them in root path.

Shreesh, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response