this is my modified code please help me
here i have included the files of my project , please help me
[B]DEFAULT.ASPX.CS[/B]
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.IO;
using System.Xml.Linq;
using System.Data.SqlClient;
using System.Windows.Forms;
//using System.Web.
public partial class _Default : System.Web.UI.Page
{
//con.ConnectionString =SqlConnection con = new SqlConnection();
public SqlConnection con = new SqlConnection();
protected void Page_Load(object sender, EventArgs e)
{
con.ConnectionString = "Data Source=HOME-PC\\SQLEXPRESS;Initial Catalog=imagek;Integrated Security=True";
//if(!Roles.RoleExists("admin"))
//{}
}
protected void Button1_Click(object sender, EventArgs e)
{
if (FileUpload1.HasFile)
{
con.Open();
byte[] img = new byte[FileUpload1.PostedFile.ContentLength];
HttpPostedFile myimg = FileUpload1.PostedFile;
myimg.InputStream.Read(img, 0, FileUpload1.PostedFile.ContentLength);
SqlCommand cmd = new SqlCommand("insert into image values(22,'"+ img +"')",con);
cmd.ExecuteNonQuery();
con.Close();
}
}
protected void Button2_Click(object sender, EventArgs e)
{ DataSet ds = new DataSet();
con.Open();
SqlCommand command = new SqlCommand("SELECT id from image ", con);
// SqlCommand command = new SqlCommand("SELECT imagename,ImageID from [Image]", connection);
SqlDataAdapter daimages = new SqlDataAdapter(command);
DataTable dt = new DataTable();
daimages.Fill(dt);
GridView1.DataSource = dt;
GridView1.DataBind();
GridView1.Attributes.Add("bordercolor", "black");
Image img = new Image();
// ImageMap1.DataSource = ds;
}
}
[B]WEB.CONFIG[/B]
<configuration>
<configsections>
<sectiongroup name="system.web.extensions" type="System.Web.Configuration.SystemWebExtensionsSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
<sectiongroup name="scripting" type="System.Web.Configuration.ScriptingSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
<sectiongroup name="webServices" type="System.Web.Configuration.ScriptingWebServicesSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
<appsettings>
<connectionstrings>
<add name="imagekConnectionString" connectionstring="Data Source=home-pc\sqlexpress;Initial Catalog=imagek;Integrated Security=True">
providerName="System.Data.SqlClient" />
<system.web>
<compilation debug="true">
<assemblies>
<add assembly="System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089">
<add assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
<add assembly="System.Data.DataSetExtensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089">
<add assembly="System.Xml.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089">
<add assembly="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089">
<authentication mode="Windows">
<pages>
<controls>
<add tagprefix="asp" namespace="System.Web.UI" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
<add tagprefix="asp" namespace="System.Web.UI.WebControls" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
<httphandlers>
<remove verb="*" path="*.asmx">
<add verb="*" path="*.asmx" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
<add verb="*" path="*_AppService.axd" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
<add verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" validate="false">
<httpmodules>
<add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
<system.codedom>
<compilers>
<compiler language="c#;cs;csharp" extension=".cs" warninglevel="4" type="Microsoft.CSharp.CSharpCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<provideroption name="CompilerVersion" value="v3.5">
<provideroption name="WarnAsError" value="false">
<compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" warninglevel="4" type="Microsoft.VisualBasic.VBCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<provideroption name="CompilerVersion" value="v3.5">
<provideroption name="OptionInfer" value="true">
<provideroption name="WarnAsError" value="false">
<system.webserver>
<validation validateintegratedmodeconfiguration="false">
<modules>
<remove name="ScriptModule">
<add name="ScriptModule" precondition="managedHandler" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
<handlers>
<remove name="WebServiceHandlerFactory-Integrated">
<remove name="ScriptHandlerFactory">
<remove name="ScriptHandlerFactoryAppServices">
<remove name="ScriptResource">
<add name="ScriptHandlerFactory" verb="*" path="*.asmx" precondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
<add name="ScriptHandlerFactoryAppServices" verb="*" path="*_AppService.axd" precondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
<add name="ScriptResource" precondition="integratedMode" verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
<runtime>
<assemblybinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentassembly>
<assemblyidentity name="System.Web.Extensions" publickeytoken="31bf3856ad364e35">
<bindingredirect oldversion="1.0.0.0-1.1.0.0" newversion="3.5.0.0">
<dependentassembly>
<assemblyidentity name="System.Web.Extensions.Design" publickeytoken="31bf3856ad364e35">
<bindingredirect oldversion="1.0.0.0-1.1.0.0" newversion="3.5.0.0">
[B] GENERIC HANDLER[/B]
]]>
using System;
using System.Web;
using System.Data.SqlClient;
public class Handler : IHttpHandler {
public void ProcessRequest (HttpContext context) {
string imageid = context.Request.QueryString["ImID"];
SqlConnection con = new SqlConnection();
con.ConnectionString = "Data Source=HOME-PC\\SQLEXPRESS;Initial Catalog=imagek;Integrated Security=True";
con.Open();
SqlCommand command = new SqlCommand("SELECT imagefile from image ", con);
SqlDataReader dr = command.ExecuteReader();
dr.Read();
context.Response.BinaryWrite((Byte[])dr[0]);
//context.Response.ContentType = "text/plain";
//context.Response.Write("Hello World");
con.Close();
context.Response.End();
}
public bool IsReusable {
get {
return true ;
}
}
}
[B]DEFAULT ASPX[/B]
]]>