Click here to Skip to main content
15,894,180 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
namespace photo
  {
    public partial class WebForm1 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
        }
        protected void Button1_Click(object sender, EventArgs e)
         {
             onflbload(sender, e);
         }
        public void onflbload(object sender, EventArgs e)
       {
        // Create a byte[] from the input file
        int len = flbload.PostedFile.ContentLength;
        byte[] pic = new byte[len];
        flbload.PostedFile.InputStream.Read(pic, 0, len);
        // Insert the image and comment into the database
        SqlConnection connection = new SqlConnection(@"Data Source=DEVI\SQLEXPRESS; 
                          Initial Catalog =cat; Integrated Security=SSPI");
        try
        {
            connection.Open();
            SqlCommand cmd = new SqlCommand("insert into tblphotosettings "+ "(BillNo,CustomerName,Address,StartDate,EndDate,Systemurl,Numberofcopies,Amount,Total ) values (@BillNo,@CustomerName,@Address,@StartDate,@EndDate,@Systemurl,@Numberofcopies,@Amount,@Total)", connection);
            cmd.Parameters.Add("@BillNo", SqlDbType.NVarChar).Value = TextBox1.Text;
            cmd.Parameters.Add("@CustomerName", SqlDbType.NVarChar).Value =TextBox2.Text;
            cmd.Parameters.Add("@Address", SqlDbType.NVarChar).Value = TextBox3.Text;
            cmd.Parameters.Add("@StartDate", SqlDbType.NVarChar).Value =Rdbsdate.SelectedDate;
            cmd.Parameters.Add("@EndDate", SqlDbType.NVarChar).Value =Rdbddate.SelectedDate;
            cmd.Parameters.Add("@Systemurl", SqlDbType.Image).Value = pic;
            SqlParameter Src = new SqlParameter("@FilePath", SqlDbType.VarChar, 450);
            cmd.Parameters.Add(Src);
            cmd.Parameters.Add("@Numberofcopies", SqlDbType.NVarChar).Value =TextBox7.Text;
            cmd.Parameters.Add("@Amount", SqlDbType.NVarChar).Value = TextBox8.Text;
            cmd.Parameters.Add("@Total", SqlDbType.NVarChar).Value = TextBox9.Text;
            cmd.ExecuteNonQuery();
        }
        finally
        {
            connection.Close();
        }
    }
}
}
My Error
The parameterized query '(@BillNo nvarchar(2),@CustomerName nvarchar(2),@Address nvarchar' expects the parameter '@FilePath', which was not supplied.but iwant imagefile path how to change in my code
Posted
Updated 5-Apr-11 23:50pm
v4

Since your code is identical to the code posted yesterday by someone else, I will just point you to the answer which fixed it for him: [Repost] image file name not stored[^]
 
Share this answer
 
Comments
kannan 2 6-Apr-11 3:21am    
no repost i am new
OriginalGriff 6-Apr-11 3:54am    
Wasn't suggesting it was a repost: Just that since the code is identical, the solution is also - check it out!
kannan 2 6-Apr-11 4:54am    
how to store image name
OriginalGriff 6-Apr-11 6:08am    
Read the solution in the link: it fixes your problem!
The variable pic is a byte array and it does not have a method GetName. You are trying to use that here:

Src.Value = pic.GetName();


You should get the file name from the FileUpload control you are using and manually append the path where you are saving in the server.

Update: You have to provide the file name. You are not doing that. You should get it from the FileUpload control and then set it as the value for fileName parameter.
 
Share this answer
 
v2
Comments
kannan 2 6-Apr-11 4:25am    
error
The parameterized query '(@BillNo nvarchar(2),@CustomerName nvarchar(6),@Address nvarchar' expects the parameter '@FilePath', which was not supplied.
dan!sh 6-Apr-11 8:14am    
Updated the reply.

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