Bienvenidos

Recuerda que tus comentarios son importantes y recuerda agradecer si te fue útil algun artículo publicado aquí.

L1f3 15 a D@nc3 Flo0r

sábado, 8 de diciembre de 2007

Adding Images to a ReportViewer Report

An image is a report item that contains a reference to an image that is stored on the report server, embedded within the report, or stored in a database. An image can be a logo or picture that appears once on the report or it can be a picture that is repeated with rows of data. You can also use an image as a background for certain report items. You can get images from the following sources:

  • Database
  • External file share or Web site
  • Embedded locally within the report

You cannot use image files that have been added to a project.

Data-bound images can be displayed from binary data stored in a database. For example, the pictures that appear alongside product names in a product list are database images.

External images are specified as a URL that points to an image file. External images work well for logos and static pictures that are shared among several reports or Web pages.

Local report images are embedded in the report and then referenced. The image data is stored within the report definition and does not exist as a separate file. Embedded images ensure that the images are always available to the report, but they cannot be shared. Embedding an image increases the size of the report definition file. When you embed an image, Report Designer MIME-encodes the image and then stores it as text in the report definition.

How to add an Embedded Image to a Report

  1. Open the client report definition (.rdlc) file in graphical design mode.
  2. From the Report menu, select Embedded Images and add all of the images that you want to use in the report. If the Report menu is not available, click within the report design area.
  3. Drag the image control from the toolbox to the report layout. You must use the image control that is used for ReportViewer reports.
  4. Select the image and then open the Properties window in Visual Studio.
  5. Set Source to Embedded.
  6. Set Value to an image that is embedded in the report definition. You can choose which image to use from a drop-down list.

Using an External or Database Image to a Report

To use a database image, you can specify the database field that contains the image as long as the MIME type is JPG, PNG, or BMP. If the image is stored as a binary object, you must write an expression that converts the image to a supported type.

Using external images in a ReportViewer report is not enabled by default. To use an external image, you must set the EnableExternalImages property in your code. Depending on your network configuration, you might also need to bypass proxy settings to allow the external image to appear. You can add the following settings to the Web.config file to bypass the local proxy. When modifying your Web.config file, be sure to specify the name of the proxy server that is used in your network:

<system.net>

<defaultProxy>

<proxy usesystemdefault = "false"

bypassonlocal = "true"

proxyaddress = "http://<
proxyservername
>:80/" />

<defaultProxy>

</system.net>

Background Images

You can use an image as a background image in the body of the report or in a rectangle, text box, list, matrix, or table. A background image has the same properties as an image. You can also specify how the image is repeated to fill the background of the item.

Note

If you define a background image for the report body, but not the page header or footer, HTML reports will automatically use the same background image in all three regions of the report. If you do not want to use the background image in the header or footer, you must explicitly define a different image for those regions. If you do not want any image to appear in those regions, you can create and assign a small transparent image to the header or footer to create the effect of having no image at all.

To add a background image, do the following:

  • Open the client report definition (.rdlc) file in graphical design mode.
  • Select the report item to which you want to add a background image.

Note

Background images apply only to rectangle, text box, table, matrix, list, or report body items.

  • In the Properties window, expand BackgroundImage, and then do the following:
    • For Source, select External, Embedded, or Database.

Note

To use an image from the project, select External.

  • For Value, type or select an expression that evaluates to the source of the image.

    If the Source property is set to External, the expression must evaluate to a valid path to an image. This can be a static path to an image hosted on a report server, or it can be a path based on a field. If the image is stored in the project, type the name of the image as it appears in the project.

    If the Source property is set to Embedded, the expression must evaluate to the name of an image that is embedded in the report. If the Source property is set to Database, the expression must evaluate to a field that contains binary image data.

  • For MIMEType, select the appropriate MIME type for the image.

Note

MIMEType applies only if the Source property is set to Database. If the Source property is set to External or Embedded, the value of MIMEType is ignored.

For BackgroundRepeat, select Repeat, NoRepeat, RepeatX, or RepeatY.

miércoles, 28 de noviembre de 2007

Poner el numero de secuencia en un GridView

Para esto agregamos un template field

Y luego ponemos este código en el mismo

<asp:TemplateField>

<ItemTemplate>

<%# Container.DataItemIndex + 1 %>

</ItemTemplate>

</asp:TemplateField>

viernes, 2 de noviembre de 2007

Habilitar el registry cuando te sale el msg de que no puede entrar al registry porque ha sido desabilitado por el administrador

Registry Editing has been disabled by your administrator

The way to get into registry editing is simple. Open your start menu click Run and paste in the following command: REG add HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\System /v DisableRegistryTools /t REG_DWORD /d 0 /f

domingo, 23 de septiembre de 2007

Prueba de Blog desde Word

Esta es una nueva funcionalidad de MS Word que te permite escribir el articulo desde este y lo postea en tu blog automaticamente

Cheers!

sábado, 22 de septiembre de 2007

Objeto conexion con AppSettings

en la pagina
SqlConnection conn = new SqlConnection(System.Configuration.ConfigurationManager.AppSettings.Get("Connstr"));

en el webconfig
appSettings
add key="Connstr" value="Data Source=.;Initial Catalog=EvalPortales;User ID=[dbusr]"/
/appSettings

nota: poner los <> en cada linea en la parte de webconfig


Tomar el valor de objetos dentro de un datalist

Si necesitamos hacer por ejemplo un cuestionario donde las preguntas vengan desde una base de datos, pero cada pregunta tenga un RadioButtonList para seleccionar una respuesta X, debemos usar un Datalist para desplegar todo,.. pero como tomamos el valor de cada RadioButton en cada pregunta??

//recorremos el datalist
for (int x = 0; x < DataList1.Items.Count; x++)
{
//buscamos los radiobutton dentro del datalist y lo asignamos a un objeto radiobutton creado por nosotrosRadioButtonList rbl = (RadioButtonList)DataList1.Items[x].FindControl("RadioButtonList1");
//asignamos el valor a una variable
string radio = rbl.SelectedValue.ToString();
}

entonces con la variable "radio" podemos hacer lo que querramos.


Thankx to Ing. Raul Roa

miércoles, 15 de agosto de 2007

Reemplazar caracteres por otros en SQL

Para reemplazar un caracter por otro en sql server
la clausula utilizada es REPLACE

uso: REPLACE(cadena1, cadena2, cadena3)

cadena 1 = es el campo donde esta lo que queremos reemplazar
cadena 2 = es el string que queremos reemplazar
cadena 3 = es el string por el que vamos a reemplazar el anterior

ej: REPLACE('jose-benzan', '-', '@')

resultado = jose@benzan

En un query seria:

select replace(Concepto,'BALANCE PENDIENTE', 'CUENTAS POR COBRAR') from BalancePendiente

y para actualizar los valores de un campo:

update BalancePendiente
Set Concepto = replace(Concepto,'BALANCE PEDIENTE', 'CUENTAS POR COBRAR')

lunes, 25 de junio de 2007

Seleccionar una parte de un Campo en Sql Server

Si queremos seleccionar solamente una parte de un campo, por ejemplo tenemos un campo llamado MiddleName y solo queremos las 3 primeras letra de ese campo, utilizamos la cláusula "SUBSTRING"

Modo de Empleo

SUBSTRING(campo, [inicio], [tamano])

Ej:
Substring(MiddleName, 1 , 3)

si el middlename es "Rafael".. el query devolveria "Raf"

sábado, 5 de mayo de 2007

Ponerle un valor a un campo cuando viene NULL en el SELECT

Si hacemos una busqueda y tenemos campos que pueden venir con NULL y no queremos que salga la palabra NULL entonces podemos poner por ejemplo que salga un 0(cero)
con el siguiente codigo

SELECT ISNULL(campo,0) FROM TABLA


eso te imprimira un "0" en el campo en vez de "NULL"

sábado, 28 de abril de 2007

Insertar en una tabla nueva el resultado de una busqueda

Si hacemos una busqueda y queremos crear una tabla con esos datos no tenemos que cojer esa lucha creando una tabla que tenga los campos exactos de la busqueda y luego insertar esos datos, lo que hacemos es lo siguiente: despues del select y antes del from, escribimos la clausula into (tabla x) y luego el from y bla bla bla.. y lo mejor del caso es que el mismo crea la tabla con los campos y todo. :D

ex.

SELECT *
INTO TABLANUEVA
FROM TABLA1

jueves, 26 de abril de 2007

Clausula IN / NOT IN

Se utiliza cuando queremos saber si un valor en especifico de un campo se encuentra dentro de otra busqueda.

ejemplo tenemos un grupo de estudiantes y otro grupo de profesores
queremos buscar cuales estudiantes tambien son profesores, decimos

select nombre, apellido from estudiante where cedula IN (select nombre, apellido from profesores)

asi sabemos cuales estudiantes estan dentro de la consulta de profesores

Clausula Having

Se utiliza cuando queremos usar un campo calculado como filtro
ej.

queremos buscar las personas que esten repetidas mas de una vez en una lista

select count(codigo)
from tblPersonas
having count(codigo) > 1

sábado, 21 de abril de 2007

Crear una tabla en sql server

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[Clases]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[Clases]
GO

CREATE TABLE [dbo].[Clases] (
[ID_Clase] [int] IDENTITY (1, 1) NOT NULL ,
[id_Curso] [int] NULL ,
[ID_Departamento] [int] NOT NULL ,
[Fecha_Inicio] [datetime] NULL ,
[Fecha_Fin] [datetime] NULL ,
[Localidad] [varchar] (100)
COLLATE SQL_Latin1_General_CP1_CI_AS NULL ) ON [PRIMARY]
GO

jueves, 12 de abril de 2007

UPDATE A UNA TABLA

CREATE PROCEDURE [update_Corredor_Metavolante_1]

(@gan_met_id_1 [int],
@gan_met_id_2 [int],
@corredor_id_3 [int],
@metavolante_id_4 [int])

AS UPDATE [dbCiclismo].[dbo].[Corredor_Metavolante]

SET [gan_met_id] = @gan_met_id_2,
[corredor_id] = @corredor_id_3,
[metavolante_id] = @metavolante_id_4

WHERE ( [gan_met_id] = @gan_met_id_1)

viernes, 16 de febrero de 2007

The GridView fired event PageIndexChanging / Sorting which wasn't handled.



private string ConvertSortDirectionToSql(SortDirection sortDireciton)
{
string newSortDirection = String.Empty;

switch (sortDirection)
{
case SortDirection.Ascending:
newSortDirection = "ASC";
break;

case SortDirection.Descending:
newSortDirection = "DESC";
break;
}

return newSortDirection
}

protected void gridView_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
// Add here your method for DataBinding
BindGridControl();


gridView.PageIndex = e.NewPageIndex;
gridView.DataBind();
}

protected void gridView_Sorting(object sender, GridViewSortEventArgs e)
{
DataTable dataTable = gridView.DataSource as DataTable;

if (dataTable != null)
{
DataView dataView = new DataView(dataTable);
dataView.Sort = e.SortExpression + " " + ConvertSortDirectionToSql(e.SortDirection);

gridView.DataSource = dataView;
gridView.DataBind();
}
}

lunes, 12 de febrero de 2007

Guargar en BD los datos de un checkboxlist con un FOR

Esto es si queremos guardar en una BD todos los datos seleccionados en un CheckBoxList, utilizando un for.

protected void Button1_Click(object sender, EventArgs e)
{
int i;
for (i = 0; i < CheckBoxList1.Items.Count - 1; i++)
{
if (CheckBoxList1.Items[i].Selected)
{
objcmd = new SqlCommand("insert_Hospital_Copa", objconn);
objcmd.CommandType = CommandType.StoredProcedure;
objcmd.Parameters.AddWithValue("@hospital_id", GridView1.SelectedDataKey.Value);
objcmd.Parameters.AddWithValue("@copa", CheckBoxList1.Items[i].Text);
objconn.Open();
objcmd.ExecuteNonQuery();
lblmsg.Text = "Los datos han sido insertados";
objconn.Close();
}
}
}

jueves, 1 de febrero de 2007

la dll de AJAX existe en dos directorios

The type 'xxxx' exists in both '...\v2.0.50727\Temporary\....xxx.dll' and '...\v2.0.50727\Temporary\...yyy.dll'
Location:
BlogsMäx's blog

Posted by: m.unterauer
01.03.2006
This error occurs, if you have declared a class twice in your application (in a referenced assembly, somewhere in your app_code directory, or anywhere else in your app).In my case I had a prior compiled version (a dll) of the web app itself in the bin directory, which is not allowed any more. -> delete all compiled versions of all web applications (the app itself and referenced web apps) from the bin directory !!If you have to have the same classname multiple times within your application (e.g a class "DataAccess" within each module subfolder in the app_code directory, you could do the following:1) Give each class a different namespace (e.g. MODULENAME.DataAccess)2) Mark the classes as partial classes (!! this does not work if the partial classes are spread accross different subfolders of the app_code dir which are marked as codeSubDirectory in the web.config. The reason is, that in this case, each subfolder results in a different assembly and partial classes over multiple assemblies are not allowed. Also see my blog entry for creating multiple assemblies from the app_code directory !!)

jueves, 11 de enero de 2007

@@Identity

@@Identity
Many TSQL books show you how to use @@Identity to get the identity of the most recently added row. Many articles online, or in magazines show the same. What you might not know is that it is potentially a source for some very hard to trace bugs in your application.
@@Identity is potentially a very, very bad thing! In almost every case, you should use scope_identity() instead.
Why? @@Identity returns the most recently created identity for your current connection. When you first use it, it might be fine. Until someone adds a trigger. If the trigger causes another identity to be created, guess which identity you'll get in your call to @@Identity? Not nice.
scope_identity() is much nicer. It gives you what you're expecting.

SELECT SCOPE_IDENTITY() at the end of the query