why path is not passed while variables have correct values stored in them?
how to solve it?
string FilePath;
protected void BtnUpload_Click(object sender, EventArgs e)
{
if (FileUpload1.PostedFile != null)
{
File_Name = Path.GetFileName(FileUpload1.PostedFile.FileName);
FileExt = System.IO.Path.GetExtension(FileUpload1.FileName);
Response.Write(File_Name);
ss = Server.MapPath("~/Images/");
FilePath = ss + File_Name;
if (FileExt.ToLower() == ".jpg" || FileExt.ToLower() == ".jpeg" || FileExt.ToLower() == ".png" || FileExt.ToLower() == ".gif")
{
FileUpload1.SaveAs(ss + FileUpload1.FileName);
Image1.ImageUrl = "~/Images/"+ FileUpload1.FileName;
}
else
{
Response.Write("Please Select an Image File..!");
}
}
protected void BtnSubmit_Click(object sender, EventArgs e)
{
SqlCommand cmd1 = new SqlCommand("Usp_UploadImage1", con);
cmd1.CommandType = CommandType.StoredProcedure;
cmd1.Parameters.Add(new SqlParameter("@User_Id", SqlDbType.VarChar, 100));
cmd1.Parameters["@User_Id"].Value = id;
cmd1.Parameters.Add(new SqlParameter("@Name", SqlDbType.VarChar, 100));
cmd1.Parameters["@Name"].Value = TxtImageName.Text.Trim();
cmd1.Parameters.Add(new SqlParameter("@Descrip", SqlDbType.VarChar, 100));
cmd1.Parameters["@Descrip"].Value = TxtImageDescription.Text.Trim();
cmd1.Parameters.Add(new SqlParameter("@Imagecategory_Id", SqlDbType.Int));
cmd1.Parameters["@Imagecategory_Id"].Value = DrpImageCatagory.SelectedIndex;
cmd1.Parameters.Add(new SqlParameter("@Date", SqlDbType.DateTime));
cmd1.Parameters["@Date"].Value = System.DateTime.Now;
cmd1.Parameters.Add(new SqlParameter("@Path", SqlDbType.VarChar,200));
cmd1.Parameters["@Path"].Value = FilePath;
cmd1.Parameters.Add(new SqlParameter("@Status", SqlDbType.Int));
cmd1.Parameters["@Status"].Value = status;
cmd1.Parameters.Add(new SqlParameter("@ImageType_Id", SqlDbType.Int));
cmd1.Parameters["@ImageType_Id"].Value = RadioImageType.SelectedValue;
int rowcount = cmd1.ExecuteNonQuery();
con.Close();
if (rowcount > 0)
{
LblStatus.Text = "Data Inserted Successful..!";
}
}
Database: (stored procedure)
Create proc Usp_UploadImage1(@User_Id varchar(100), @Name varchar(50), @Descrip varchar(100), @Imagecategory_Id int, @Date datetime, @Path varchar(max), @Status bit, @ImageType_Id int)
as begin
insert into ImageRepository values(@User_Id, @Name, @Descrip, @Imagecategory_Id, @Date, @Path, @Status, @ImageType_Id)
end
Every thing works fine. but execution gives stated error:
Procedure or function 'Usp_UploadImage1' expects parameter '@Path', which was not supplied
when i debug that, it shows that Filepath1 has correct path
but is was not passed..!! why? and how can i solve it?