My favorites | Sign in
Project Home Downloads Wiki Issues Source
Repository:
Checkout   Browse   Changes   Clones    
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
using System;
using System.Web.UI;
using System.Data.SqlClient;
using System.Data;
using System.Configuration;

public partial class _Default : System.Web.UI.Page
{
protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
{
ScriptManager.RegisterStartupScript(Page, Page.GetType(), "script_popup_imagem", string.Concat("window.open('", ResolveUrl("~/GerarImagem.ashx?id="), GridView1.SelectedValue, "', 'Imagem', 'width=800, height=600')"), true);
}
protected void btnEnviar_Click(object sender, EventArgs e)
{
SqlConnection conexao = new SqlConnection(ConfigurationManager.ConnectionStrings["SqlConnectionStringSqlServer"].ConnectionString);
try
{
conexao.Open();
SqlCommand comando = new SqlCommand("INSERT INTO [DotNet_Gravar_e_Ler_Imagem_no_Banco_de_dados] (Imagem) VALUES (@Imagem) ", conexao);
comando.Parameters.Add("@Imagem", SqlDbType.Image).Value = FileUploadImagem.FileBytes; // O "FileUploadImagem" é a ID do controle FileUpload
comando.ExecuteNonQuery();
GridView1.DataBind();
}
finally
{
conexao.Close();
}
}
}

Change log

d844e23324d1 by yccodigo on May 2, 2010   Diff
a
Go to: 
Project members, sign in to write a code review

Older revisions

486809c61d4f by yccodigo on May 1, 2010   Diff
1
All revisions of this file

File info

Size: 1236 bytes, 29 lines
Powered by Google Project Hosting