Presentation Layer
:
protected void Button2_Click(object sender, EventArgs e)
{
lblMessage.Visible = true;
p.ProductType = txtName.Text;
if (FileUpload1.PostedFile != null &&
FileUpload1.PostedFile.FileName != "")
{
byte[] imageSize = new byte
[FileUpload1.PostedFile.ContentLength];
HttpPostedFile uploadedImage = FileUpload1.PostedFile;
uploadedImage.InputStream.Read
(imageSize, 0,
(int)FileUpload1.PostedFile.ContentLength);
p.Image = imageSize;
}
p.InsertProducts();
lblMessage.Text = "File Uploaded";
}
Business Access Layer
public void InsertProducts()
{
SqlParameter[] p=new SqlParameter[2];
p[0]=new SqlParameter("@ProductType",producttype);
p[0].DbType=DbType.String;
p[1]=new SqlParameter("Image",image);
SqlHelper.ExecuteNonQuery(clsConnection.Connection,
CommandType.StoredProcedure, "sp_InsertProducts", p);
}
// Here "sp_InsertProducts" is the stored procedure Name.
Data Access Layer
public class clsConnection
{
public clsConnection()
{
//
// TODO: Add constructor logic here
//
}
public static string Connection =
ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
}
Under Web.Config
<connectionStrings>
<add name="ConnectionString" connectionString="user
Id=sa;Password=123;DataBase=RentalShopping;Data Source=server2"
providerName="System.Data.SqlClient"/>
</connectionStrings>
//Here write your database name,userid,password,datasource.
Under DataBase:
Create one database i.e RentalShopping.Under Database create one
table.I have created one table i.e Products.
CREATE TABLE [dbo].[Products]
(
[ProductId] [int] IDENTITY(101,1) NOT NULL,
[ProductType] [varchar](50) NULL,
[Image] [image] NULL
}
This is the stored procedure
USE [RentalShopping]
GO
-SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[sp_InsertProducts](@ProductType
varchar(50),@Image image)
as
begin
insert into Products(ProductType,Image)values(@ProductType,@Image)
end
On Aug 5, 8:01 pm, ravilla srinubabu <[email protected]>
wrote:
> *How can i write c# code to generate image from binary data .....
> * *Regards*
> *~~~~~~~~~~~~~~**
> Srinubabu R**
> 970-132-5332*
--
You received this message because you are subscribed to the Google
Groups "DotNetDevelopment, VB.NET, C# .NET, ADO.NET, ASP.NET, XML, XML
Web Services,.NET Remoting" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/dotnetdevelopment?hl=en?hl=en
or visit the group website at http://megasolutions.net