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)
{
int len = flbload.PostedFile.ContentLength;
byte[] pic = new byte[len];
flbload.PostedFile.InputStream.Read(pic, 0, len);
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