Click here to Skip to main content
15,885,546 members
Please Sign up or sign in to vote.
1.00/5 (6 votes)
See more:
I have created a website and I have to insert the customer record and image insert and image file path name
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");
            SqlConnection con = new SqlConnection();
            con.ConnectionString = @"Data Source=DEVI\SQLEXPRESS; Initial Catalog =cat; Integrated Security=SSPI";
            try
            {
                connection.Open();
                SqlCommand cmd = new SqlCommand();
                cmd.CommandText = "photoset";
                cmd.CommandType = CommandType.StoredProcedure;
                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);
                Src.Value = flbload.PostedFile.FileName;
                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.Connection = con;
                con.Open();
                cmd.ExecuteNonQuery();
            }
            finally
            {
                connection.Close();
            }
        }
    }
}
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[photoset]
(
@BillNo Numeric,
@CustomerName Nvarchar(300),
@Address Nvarchar(300),
@StartDate datetime,
@EndDate datetime,
@Systemurl image,
@Filepath Nvarchar,
@Numberofcopies Numeric,
@Amount Numeric,
@Total Numeric
)
 
AS
BEGIN
 insert into tblphotosettings
(
BillNo,
CustomerName,
Address,
StartDate,
EndDate,
Systemurl,
Filepath,
Numberofcopies,
Amount,
Total
)
values
(
@BillNo,
@CustomerName,
@Address,
@StartDate,
@EndDate,
@Systemurl,
@Filepath,
@Numberofcopies,
@Amount,
@Total
)
END

My Error All record are insert but file name not insert
Posted
Updated 7-Apr-11 23:33pm
v2
Comments
jim lahey 8-Apr-11 5:22am    
please also post the code of your stored procedure
kannan 2 8-Apr-11 5:38am    
i edit the code
kannan 2 8-Apr-11 6:01am    
thank you so much
dan!sh 8-Apr-11 5:23am    
You have asked this question a number of times now. Have you debugged ans checked why? Is it even passed with the command?
#realJSOP 8-Apr-11 5:26am    
STOP reposting the same question over and over again. If someone can (or wants to) help you, they will...

Changing the subject of your question will not change the results: Read the answers to the last five times you have asked this question, and try learn to think!
 
Share this answer
 
Assuming you mean Filepath, the problem may be here:

@Filepath Nvarchar


Try adding a length to your parameter declaration and see if it helps:

@Filepath Nvarchar(450)
 
Share this answer
 
Comments
kannan 2 8-Apr-11 5:52am    
thank you so much

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