Showing posts with label browser. Show all posts
Showing posts with label browser. Show all posts

Wednesday, March 28, 2012

Images not being displayed.

1. I am using the webservice to render the images from a report, and they dont render.

I paste this URL to the browser

http://agamenon:90/ReportServer?%2fGescomRpts%2fRPT_MediosDesarrollo&rs%3aFormat=HTML4.0&rs:ImageID=6c809239-753f-4988-abcf-231416dff0d6

and I get this

No se encuentra la secuencia. No se encuentra el identificador de secuencia proporcionado a una operación en la base de datos del servidor de informes. (rsStreamNotFound) Obtener ayuda en pantalla

This is the code

the problem is that I need to know the streamid, and to know the streamid I first have to render the report where the image is to be placed.

This is the page getimage.aspx

protected void Page_Load(object sender, EventArgs e)

{

string reportPath = Server.UrlDecode(Request["report"]);

//string streamID = Request["streamid"];

ReportExecutionService rs = (ReportExecutionService)Session["rs"];

DataSourceCredentials[] credentials = null;

string showHideToggle = null;

string encoding;

string mimeType;

string extension;

Warning[] warnings = null;

ParameterValue[] reportHistoryParameters = null;

string historyID = null;

string[] streamIDs = null;

ServerInfoHeader sh = new ServerInfoHeader();

rs.ServerInfoHeaderValue = sh;

byte[] result = null;

ParameterValue[] reportParameterValues2 = null;

string deviceInfo = "<DeviceInfo>" +

//"<StreamRoot>" + streamRoot + "</StreamRoot>" +

"<Toolbar>False</Toolbar>" +

"<Parameters>False</Parameters>" +

"<HTMLFragment>True</HTMLFragment>" +

"<StyleStream>False</StyleStream>" +

"<Section>0</Section>" +

"<Zoom>" +

"</Zoom>" +

"</DeviceInfo>";

result = rs.Render("HTML4.0", deviceInfo, out extension, out mimeType, out encoding, out warnings, out streamIDs);

string streamID = streamIDs[0];

string encodingImage;

string mimeTypeImage;

byte[] image;

ParameterValue[] pv = (ParameterValue[])Session["reportParameterValues"];

//image = rs.RenderStream(reportPath, "HTML4.0", streamID, null, null, pv, out encodingImage, out mimeTypeImage);

image=rs.RenderStream("HTML4.0", streamID, null, out encodingImage, out mimeTypeImage);

Response.Clear();

Response.ContentType = mimeTypeImage;

Response.AppendHeader("content-length", image.Length.ToString());

Response.BinaryWrite(image);

Response.Flush();

Response.Close();

}

and this is the page of the report. Sorry for the long code.

if (reportCanBeRendered)

{

string deviceInfo;

string streamRoot;

Session["rs"] = rs;

streamRoot = ("getimage.aspx?report="+ (path + "&streamid="));

switch (format)

{

case "HTML4.0":

case "HTML3.2":

deviceInfo = "<DeviceInfo>" +

"<StreamRoot></StreamRoot>" +

"<Toolbar>False</Toolbar>" +

"<Parameters>False</Parameters>" +

"<HTMLFragment>True</HTMLFragment>" +

"<StyleStream>False</StyleStream>" +

"<Section>0</Section>" +

"<Zoom>" +

"</Zoom>" +

"</DeviceInfo>";

break;

default:

deviceInfo = "<DeviceInfo></DeviceInfo>";

break;

}

// SQLRS-ReportViewer

if (!(reportParameterValues == null))

{

//reportParameterValues2 = reportParameterValues.ToArray(typeof(ParameterValue));

//reportParameterValues2 = (ParameterValue[])reportParameterValues.ToArray(typeof(ParameterValue));

}

DataSourceCredentials[] credentials = null;

string showHideToggle = null;

string encoding;

string mimeType;

string extension;

Warning[] warnings = null;

ParameterValue[] reportHistoryParameters = null;

string historyID = null;

string[] streamIDs = null;

ServerInfoHeader sh = new ServerInfoHeader();

rs.ServerInfoHeaderValue = sh;

byte[] result = null;

ParameterValue[] reportParameterValues2 = null;

result = rs.Render(format, deviceInfo, out extension, out mimeType, out encoding, out warnings, out streamIDs);

streamRoot = "getimage.aspx?report=" + path + "&amp;streamid=" + streamIDs[0];

//string reportPath2 = Server.UrlDecode(Request["report"]);

//string streamID = streamIDs[0];

////string streamID = "";

//ReportExecutionService rs2 = new ReportExecutionService();

//Session["rs"] = rs;

//rs2=(ReportExecutionService)Session["rs"];

//////ReportingService rs = (ReportingService)Session["rs"];

//string encodingImage;

//string mimeTypeImage;

//byte[] image;

//ParameterValue[] pv = (ParameterValue[])Session["reportParameterValues"];

//////image = rs.RenderStream(reportPath, "HTML4.0", streamID, null, null, pv, out encodingImage, out mimeTypeImage);

//image = rs2.RenderStream("HTML4.0", streamID, null, out encodingImage, out mimeTypeImage);

//Response.Clear();

//Response.ContentType = mimeTypeImage;

//Response.AppendHeader("content-length", image.Length.ToString());

//Response.BinaryWrite(image);

//Response.Flush();

//Response.Close();

// store ReportingServices and parameters object is session layer in case we need it for image streams

Session["rs"] = rs;

Session["reportParameterValues"] = reportParameterValues2;

switch (format)

{

case "HTML4.0":

case "HTML3.2":

System.Text.Encoding enc = System.Text.Encoding.UTF8;

// get the report as a string

string tmpReport = enc.GetString(result);

// replace all occurrences of report server link with current page link

tmpReport = tmpReport.Replace(reportServerURL.Replace("/ReportService.asmx", "?"), ("http://"

+ (Request["SERVER_NAME"]

+ (Request["SCRIPT_NAME"] + "?Report="))));

ReportPlaceholder.InnerHtml = tmpReport;

break;

default:

Response.ClearContent();

Response.AppendHeader("content-length", result.Length.ToString());

Response.ContentType = mimeType;

Response.BinaryWrite(result);

Response.Flush();

Response.Close();

break;

}

}

I actually solved the proble, this code has a little of garbage, but it began working.

private void GenerarInPlaceHTML()

{

string path = reportPath+ "RPT_MediosDesarrollo";

ReportExecutionService rs = new ReportExecutionService();

rs.Url = reportServerURL;

System.Net.NetworkCredential reportCredentials = new System.Net.NetworkCredential(reportUser, userPassword, domain);

rs.Credentials = reportCredentials;

// see if Report URL parameter is defined and if it is then consider that report

if (!(Request["Report"] == null))

{

reportPath = Request["Report"];

}

// set the Report hidden parameter

Report.Value = reportPath;

// Get the list of parameters. without specifing to render the report (ForRendering set to false)

// valid values for these parameters will not be populated

ExecutionInfo execInfo;

execInfo = rs.LoadReport(path, null);

ReportParameter[] reportParametersArray = execInfo.Parameters;

//reportParametersArray = rs.GetReportParameters(path, null, false, null, null);

//// If there are parametrs then we generate an array with values that should be populated from either

//// - previous submission ,

//// - URL parameters,

//// - default value defined inside the report

//// some usefull declarations

System.Web.UI.HtmlControls.HtmlTableRow TR = new HtmlTableRow();

System.Web.UI.HtmlControls.HtmlTableCell TD;

System.Web.UI.HtmlControls.HtmlSelect S;

System.Web.UI.WebControls.ListItem LI;

System.Web.UI.HtmlControls.HtmlInputText T;

//// hash table with dependecies

System.Collections.Hashtable Dependencies = new System.Collections.Hashtable();

//// we need a dynamic array for storing parameter values

ArrayList reportParameterValues= new ArrayList();

if (reportCanBeRendered)

{

string deviceInfo;

string streamRoot;

Session["rs"] = rs;

streamRoot = ("getimage.aspx?report="+ (path + "&streamid="));

switch (format)

{

case "HTML4.0":

case "HTML3.2":

deviceInfo = "<DeviceInfo>" +

"<StreamRoot>http://ImagenesTemporales/</StreamRoot>" +

"<Toolbar>False</Toolbar>" +

"<Parameters>False</Parameters>" +

"<HTMLFragment>True</HTMLFragment>" +

"<StyleStream>False</StyleStream>" +

"<Section>0</Section>" +

"<Zoom>" +

"</Zoom>" +

"</DeviceInfo>";

break;

default:

deviceInfo = "<DeviceInfo></DeviceInfo>";

break;

}

// SQLRS-ReportViewer

if (!(reportParameterValues == null))

{

//reportParameterValues2 = reportParameterValues.ToArray(typeof(ParameterValue));

//reportParameterValues2 = (ParameterValue[])reportParameterValues.ToArray(typeof(ParameterValue));

}

DataSourceCredentials[] credentials = null;

string showHideToggle = null;

string encoding;

string mimeType;

string extension;

Warning[] warnings = null;

ParameterValue[] reportHistoryParameters = null;

string historyID = null;

string[] streamIDs = null;

ServerInfoHeader sh = new ServerInfoHeader();

rs.ServerInfoHeaderValue = sh;

byte[] result = null;

ParameterValue[] reportParameterValues2 = null;

result = rs.Render(format, deviceInfo, out extension, out mimeType, out encoding, out warnings, out streamIDs);

string encodingImage;

string mimeTypeImage;

byte[] image = rs.RenderStream("HTML4.0", streamIDs[0], null, out encodingImage,out mimeTypeImage);

System.IO.FileStream fs = System.IO.File.OpenWrite(@."C:\Inetpub\wwwroot\GescomDllo\ImagenesTemporales\" + streamIDs[0]);

fs.Write(image, 0, Convert.ToInt32(image.Length));

fs.Close();

// store ReportingServices and parameters object is session layer in case we need it for image streams

Session["rs"] = rs;

Session["reportParameterValues"] = reportParameterValues2;

switch (format)

{

case "HTML4.0":

case "HTML3.2":

System.Text.Encoding enc = System.Text.Encoding.UTF8;

// get the report as a string

string tmpReport = enc.GetString(result);

// replace all occurrences of report server link with current page link

tmpReport = tmpReport.Replace(reportServerURL.Replace("/ReportService.asmx", "?"), ("http://"

+ (Request["SERVER_NAME"]

+ (Request["SCRIPT_NAME"] + "?Report="))));

ReportPlaceholder.InnerHtml = tmpReport;

break;

default:

Response.ClearContent();

Response.AppendHeader("content-length", result.Length.ToString());

Response.ContentType = mimeType;

Response.BinaryWrite(result);

Response.Flush();

Response.Close();

break;

}

}

}

|||

Thanks buddy!!!

you answer helped me, though it was tough to figure out what i was doing wrong previosly. the only mistake i was doing is here .

it should be this.

image=rs.RenderStream("HTML4.0", streamID, null, out encodingImage, out mimeTypeImage);

i was doing this.

image=rs.RenderStream("IMAGE", streamID, null, out encodingImage, out mimeTypeImage);

Thanks again

|||

Luis Esteban, tendras ese mismo codigo pero para reporting services 2000?

Saludos

Images not being displayed.

1. I am using the webservice to render the images from a report, and they dont render.

I paste this URL to the browser

http://agamenon:90/ReportServer?%2fGescomRpts%2fRPT_MediosDesarrollo&rs%3aFormat=HTML4.0&rs:ImageID=6c809239-753f-4988-abcf-231416dff0d6

and I get this

No se encuentra la secuencia. No se encuentra el identificador de secuencia proporcionado a una operación en la base de datos del servidor de informes. (rsStreamNotFound) Obtener ayuda en pantalla

This is the code

the problem is that I need to know the streamid, and to know the streamid I first have to render the report where the image is to be placed.

This is the page getimage.aspx

protectedvoid Page_Load(object sender, EventArgs e)

{

string reportPath = Server.UrlDecode(Request["report"]);

//string streamID = Request["streamid"];

ReportExecutionService rs = (ReportExecutionService)Session["rs"];

DataSourceCredentials[] credentials = null;

string showHideToggle = null;

string encoding;

string mimeType;

string extension;

Warning[] warnings = null;

ParameterValue[] reportHistoryParameters = null;

string historyID = null;

string[] streamIDs = null;

ServerInfoHeader sh = newServerInfoHeader();

rs.ServerInfoHeaderValue = sh;

byte[] result = null;

ParameterValue[] reportParameterValues2 = null;

string deviceInfo = "<DeviceInfo>" +

//"<StreamRoot>" + streamRoot + "</StreamRoot>" +

"<Toolbar>False</Toolbar>" +

"<Parameters>False</Parameters>" +

"<HTMLFragment>True</HTMLFragment>" +

"<StyleStream>False</StyleStream>" +

"<Section>0</Section>" +

"<Zoom>" +

"</Zoom>" +

"</DeviceInfo>";

result = rs.Render("HTML4.0", deviceInfo, out extension, out mimeType, out encoding, out warnings, out streamIDs);

string streamID = streamIDs[0];

string encodingImage;

string mimeTypeImage;

byte[] image;

ParameterValue[] pv = (ParameterValue[])Session["reportParameterValues"];

//image = rs.RenderStream(reportPath, "HTML4.0", streamID, null, null, pv, out encodingImage, out mimeTypeImage);

image=rs.RenderStream("HTML4.0", streamID, null, out encodingImage, out mimeTypeImage);

Response.Clear();

Response.ContentType = mimeTypeImage;

Response.AppendHeader("content-length", image.Length.ToString());

Response.BinaryWrite(image);

Response.Flush();

Response.Close();

}

and this is the page of the report. Sorry for the long code.

if (reportCanBeRendered)

{

string deviceInfo;

string streamRoot;

Session["rs"] = rs;

streamRoot = ("getimage.aspx?report="+ (path + "&streamid="));

switch (format)

{

case"HTML4.0":

case"HTML3.2":

deviceInfo = "<DeviceInfo>" +

"<StreamRoot></StreamRoot>" +

"<Toolbar>False</Toolbar>" +

"<Parameters>False</Parameters>" +

"<HTMLFragment>True</HTMLFragment>" +

"<StyleStream>False</StyleStream>" +

"<Section>0</Section>" +

"<Zoom>" +

"</Zoom>" +

"</DeviceInfo>";

break;

default:

deviceInfo = "<DeviceInfo></DeviceInfo>";

break;

}

// SQLRS-ReportViewer

if (!(reportParameterValues == null))

{

//reportParameterValues2 = reportParameterValues.ToArray(typeof(ParameterValue));

//reportParameterValues2 = (ParameterValue[])reportParameterValues.ToArray(typeof(ParameterValue));

}

DataSourceCredentials[] credentials = null;

string showHideToggle = null;

string encoding;

string mimeType;

string extension;

Warning[] warnings = null;

ParameterValue[] reportHistoryParameters = null;

string historyID = null;

string[] streamIDs = null;

ServerInfoHeader sh = newServerInfoHeader();

rs.ServerInfoHeaderValue = sh;

byte[] result = null;

ParameterValue[] reportParameterValues2 = null;

result = rs.Render(format, deviceInfo, out extension, out mimeType, out encoding, out warnings, out streamIDs);

streamRoot = "getimage.aspx?report=" + path + "&amp;streamid=" + streamIDs[0];

//string reportPath2 = Server.UrlDecode(Request["report"]);

//string streamID = streamIDs[0];

////string streamID = "";

//ReportExecutionService rs2 = new ReportExecutionService();

//Session["rs"] = rs;

//rs2=(ReportExecutionService)Session["rs"];

//////ReportingService rs = (ReportingService)Session["rs"];

//string encodingImage;

//string mimeTypeImage;

//byte[] image;

//ParameterValue[] pv = (ParameterValue[])Session["reportParameterValues"];

//////image = rs.RenderStream(reportPath, "HTML4.0", streamID, null, null, pv, out encodingImage, out mimeTypeImage);

//image = rs2.RenderStream("HTML4.0", streamID, null, out encodingImage, out mimeTypeImage);

//Response.Clear();

//Response.ContentType = mimeTypeImage;

//Response.AppendHeader("content-length", image.Length.ToString());

//Response.BinaryWrite(image);

//Response.Flush();

//Response.Close();

// store ReportingServices and parameters object is session layer in case we need it for image streams

Session["rs"] = rs;

Session["reportParameterValues"] = reportParameterValues2;

switch (format)

{

case"HTML4.0":

case"HTML3.2":

System.Text.Encoding enc = System.Text.Encoding.UTF8;

// get the report as a string

string tmpReport = enc.GetString(result);

// replace all occurrences of report server link with current page link

tmpReport = tmpReport.Replace(reportServerURL.Replace("/ReportService.asmx", "?"), ("http://"

+ (Request["SERVER_NAME"]

+ (Request["SCRIPT_NAME"] + "?Report="))));

ReportPlaceholder.InnerHtml = tmpReport;

break;

default:

Response.ClearContent();

Response.AppendHeader("content-length", result.Length.ToString());

Response.ContentType = mimeType;

Response.BinaryWrite(result);

Response.Flush();

Response.Close();

break;

}

}

I actually solved the proble, this code has a little of garbage, but it began working.

privatevoid GenerarInPlaceHTML()

{

string path = reportPath+ "RPT_MediosDesarrollo";

ReportExecutionService rs = newReportExecutionService();

rs.Url = reportServerURL;

System.Net.NetworkCredential reportCredentials = new System.Net.NetworkCredential(reportUser, userPassword, domain);

rs.Credentials = reportCredentials;

// see if Report URL parameter is defined and if it is then consider that report

if (!(Request["Report"] == null))

{

reportPath = Request["Report"];

}

// set the Report hidden parameter

Report.Value = reportPath;

// Get the list of parameters. without specifing to render the report (ForRendering set to false)

// valid values for these parameters will not be populated

ExecutionInfo execInfo;

execInfo = rs.LoadReport(path, null);

ReportParameter[] reportParametersArray = execInfo.Parameters;

//reportParametersArray = rs.GetReportParameters(path, null, false, null, null);

//// If there are parametrs then we generate an array with values that should be populated from either

//// - previous submission ,

//// - URL parameters,

//// - default value defined inside the report

//// some usefull declarations

System.Web.UI.HtmlControls.HtmlTableRow TR = newHtmlTableRow();

System.Web.UI.HtmlControls.HtmlTableCell TD;

System.Web.UI.HtmlControls.HtmlSelect S;

System.Web.UI.WebControls.ListItem LI;

System.Web.UI.HtmlControls.HtmlInputText T;

//// hash table with dependecies

System.Collections.Hashtable Dependencies = new System.Collections.Hashtable();

//// we need a dynamic array for storing parameter values

ArrayList reportParameterValues= newArrayList();

if (reportCanBeRendered)

{

string deviceInfo;

string streamRoot;

Session["rs"] = rs;

streamRoot = ("getimage.aspx?report="+ (path + "&streamid="));

switch (format)

{

case"HTML4.0":

case"HTML3.2":

deviceInfo = "<DeviceInfo>" +

"<StreamRoot>http://ImagenesTemporales/</StreamRoot>" +

"<Toolbar>False</Toolbar>" +

"<Parameters>False</Parameters>" +

"<HTMLFragment>True</HTMLFragment>" +

"<StyleStream>False</StyleStream>" +

"<Section>0</Section>" +

"<Zoom>" +

"</Zoom>" +

"</DeviceInfo>";

break;

default:

deviceInfo = "<DeviceInfo></DeviceInfo>";

break;

}

// SQLRS-ReportViewer

if (!(reportParameterValues == null))

{

//reportParameterValues2 = reportParameterValues.ToArray(typeof(ParameterValue));

//reportParameterValues2 = (ParameterValue[])reportParameterValues.ToArray(typeof(ParameterValue));

}

DataSourceCredentials[] credentials = null;

string showHideToggle = null;

string encoding;

string mimeType;

string extension;

Warning[] warnings = null;

ParameterValue[] reportHistoryParameters = null;

string historyID = null;

string[] streamIDs = null;

ServerInfoHeader sh = newServerInfoHeader();

rs.ServerInfoHeaderValue = sh;

byte[] result = null;

ParameterValue[] reportParameterValues2 = null;

result = rs.Render(format, deviceInfo, out extension, out mimeType, out encoding, out warnings, out streamIDs);

string encodingImage;

string mimeTypeImage;

byte[] image = rs.RenderStream("HTML4.0", streamIDs[0], null, out encodingImage,out mimeTypeImage);

System.IO.FileStream fs = System.IO.File.OpenWrite(@."C:\Inetpub\wwwroot\GescomDllo\ImagenesTemporales\" + streamIDs[0]);

fs.Write(image, 0, Convert.ToInt32(image.Length));

fs.Close();

// store ReportingServices and parameters object is session layer in case we need it for image streams

Session["rs"] = rs;

Session["reportParameterValues"] = reportParameterValues2;

switch (format)

{

case"HTML4.0":

case"HTML3.2":

System.Text.Encoding enc = System.Text.Encoding.UTF8;

// get the report as a string

string tmpReport = enc.GetString(result);

// replace all occurrences of report server link with current page link

tmpReport = tmpReport.Replace(reportServerURL.Replace("/ReportService.asmx", "?"), ("http://"

+ (Request["SERVER_NAME"]

+ (Request["SCRIPT_NAME"] + "?Report="))));

ReportPlaceholder.InnerHtml = tmpReport;

break;

default:

Response.ClearContent();

Response.AppendHeader("content-length", result.Length.ToString());

Response.ContentType = mimeType;

Response.BinaryWrite(result);

Response.Flush();

Response.Close();

break;

}

}

}

|||

Thanks buddy!!!

you answer helped me, though it was tough to figure out what i was doing wrong previosly. the only mistake i was doing is here .

it should be this.

image=rs.RenderStream("HTML4.0", streamID, null, out encodingImage, out mimeTypeImage);

i was doing this.

image=rs.RenderStream("IMAGE", streamID, null, out encodingImage, out mimeTypeImage);

Thanks again

|||

Luis Esteban, tendras ese mismo codigo pero para reporting services 2000?

Saludos

Images not being displayed.

1. I am using the webservice to render the images from a report, and they dont render.

I paste this URL to the browser

http://agamenon:90/ReportServer?%2fGescomRpts%2fRPT_MediosDesarrollo&rs%3aFormat=HTML4.0&rs:ImageID=6c809239-753f-4988-abcf-231416dff0d6

and I get this

No se encuentra la secuencia. No se encuentra el identificador de secuencia proporcionado a una operación en la base de datos del servidor de informes. (rsStreamNotFound) Obtener ayuda en pantalla

This is the code

the problem is that I need to know the streamid, and to know the streamid I first have to render the report where the image is to be placed.

This is the page getimage.aspx

protected void Page_Load(object sender, EventArgs e)

{

string reportPath = Server.UrlDecode(Request["report"]);

//string streamID = Request["streamid"];

ReportExecutionService rs = (ReportExecutionService)Session["rs"];

DataSourceCredentials[] credentials = null;

string showHideToggle = null;

string encoding;

string mimeType;

string extension;

Warning[] warnings = null;

ParameterValue[] reportHistoryParameters = null;

string historyID = null;

string[] streamIDs = null;

ServerInfoHeader sh = new ServerInfoHeader();

rs.ServerInfoHeaderValue = sh;

byte[] result = null;

ParameterValue[] reportParameterValues2 = null;

string deviceInfo = "<DeviceInfo>" +

//"<StreamRoot>" + streamRoot + "</StreamRoot>" +

"<Toolbar>False</Toolbar>" +

"<Parameters>False</Parameters>" +

"<HTMLFragment>True</HTMLFragment>" +

"<StyleStream>False</StyleStream>" +

"<Section>0</Section>" +

"<Zoom>" +

"</Zoom>" +

"</DeviceInfo>";

result = rs.Render("HTML4.0", deviceInfo, out extension, out mimeType, out encoding, out warnings, out streamIDs);

string streamID = streamIDs[0];

string encodingImage;

string mimeTypeImage;

byte[] image;

ParameterValue[] pv = (ParameterValue[])Session["reportParameterValues"];

//image = rs.RenderStream(reportPath, "HTML4.0", streamID, null, null, pv, out encodingImage, out mimeTypeImage);

image=rs.RenderStream("HTML4.0", streamID, null, out encodingImage, out mimeTypeImage);

Response.Clear();

Response.ContentType = mimeTypeImage;

Response.AppendHeader("content-length", image.Length.ToString());

Response.BinaryWrite(image);

Response.Flush();

Response.Close();

}

and this is the page of the report. Sorry for the long code.

if (reportCanBeRendered)

{

string deviceInfo;

string streamRoot;

Session["rs"] = rs;

streamRoot = ("getimage.aspx?report="+ (path + "&streamid="));

switch (format)

{

case "HTML4.0":

case "HTML3.2":

deviceInfo = "<DeviceInfo>" +

"<StreamRoot></StreamRoot>" +

"<Toolbar>False</Toolbar>" +

"<Parameters>False</Parameters>" +

"<HTMLFragment>True</HTMLFragment>" +

"<StyleStream>False</StyleStream>" +

"<Section>0</Section>" +

"<Zoom>" +

"</Zoom>" +

"</DeviceInfo>";

break;

default:

deviceInfo = "<DeviceInfo></DeviceInfo>";

break;

}

// SQLRS-ReportViewer

if (!(reportParameterValues == null))

{

//reportParameterValues2 = reportParameterValues.ToArray(typeof(ParameterValue));

//reportParameterValues2 = (ParameterValue[])reportParameterValues.ToArray(typeof(ParameterValue));

}

DataSourceCredentials[] credentials = null;

string showHideToggle = null;

string encoding;

string mimeType;

string extension;

Warning[] warnings = null;

ParameterValue[] reportHistoryParameters = null;

string historyID = null;

string[] streamIDs = null;

ServerInfoHeader sh = new ServerInfoHeader();

rs.ServerInfoHeaderValue = sh;

byte[] result = null;

ParameterValue[] reportParameterValues2 = null;

result = rs.Render(format, deviceInfo, out extension, out mimeType, out encoding, out warnings, out streamIDs);

streamRoot = "getimage.aspx?report=" + path + "&amp;streamid=" + streamIDs[0];

//string reportPath2 = Server.UrlDecode(Request["report"]);

//string streamID = streamIDs[0];

////string streamID = "";

//ReportExecutionService rs2 = new ReportExecutionService();

//Session["rs"] = rs;

//rs2=(ReportExecutionService)Session["rs"];

//////ReportingService rs = (ReportingService)Session["rs"];

//string encodingImage;

//string mimeTypeImage;

//byte[] image;

//ParameterValue[] pv = (ParameterValue[])Session["reportParameterValues"];

//////image = rs.RenderStream(reportPath, "HTML4.0", streamID, null, null, pv, out encodingImage, out mimeTypeImage);

//image = rs2.RenderStream("HTML4.0", streamID, null, out encodingImage, out mimeTypeImage);

//Response.Clear();

//Response.ContentType = mimeTypeImage;

//Response.AppendHeader("content-length", image.Length.ToString());

//Response.BinaryWrite(image);

//Response.Flush();

//Response.Close();

// store ReportingServices and parameters object is session layer in case we need it for image streams

Session["rs"] = rs;

Session["reportParameterValues"] = reportParameterValues2;

switch (format)

{

case "HTML4.0":

case "HTML3.2":

System.Text.Encoding enc = System.Text.Encoding.UTF8;

// get the report as a string

string tmpReport = enc.GetString(result);

// replace all occurrences of report server link with current page link

tmpReport = tmpReport.Replace(reportServerURL.Replace("/ReportService.asmx", "?"), ("http://"

+ (Request["SERVER_NAME"]

+ (Request["SCRIPT_NAME"] + "?Report="))));

ReportPlaceholder.InnerHtml = tmpReport;

break;

default:

Response.ClearContent();

Response.AppendHeader("content-length", result.Length.ToString());

Response.ContentType = mimeType;

Response.BinaryWrite(result);

Response.Flush();

Response.Close();

break;

}

}

I actually solved the proble, this code has a little of garbage, but it began working.

private void GenerarInPlaceHTML()

{

string path = reportPath+ "RPT_MediosDesarrollo";

ReportExecutionService rs = new ReportExecutionService();

rs.Url = reportServerURL;

System.Net.NetworkCredential reportCredentials = new System.Net.NetworkCredential(reportUser, userPassword, domain);

rs.Credentials = reportCredentials;

// see if Report URL parameter is defined and if it is then consider that report

if (!(Request["Report"] == null))

{

reportPath = Request["Report"];

}

// set the Report hidden parameter

Report.Value = reportPath;

// Get the list of parameters. without specifing to render the report (ForRendering set to false)

// valid values for these parameters will not be populated

ExecutionInfo execInfo;

execInfo = rs.LoadReport(path, null);

ReportParameter[] reportParametersArray = execInfo.Parameters;

//reportParametersArray = rs.GetReportParameters(path, null, false, null, null);

//// If there are parametrs then we generate an array with values that should be populated from either

//// - previous submission ,

//// - URL parameters,

//// - default value defined inside the report

//// some usefull declarations

System.Web.UI.HtmlControls.HtmlTableRow TR = new HtmlTableRow();

System.Web.UI.HtmlControls.HtmlTableCell TD;

System.Web.UI.HtmlControls.HtmlSelect S;

System.Web.UI.WebControls.ListItem LI;

System.Web.UI.HtmlControls.HtmlInputText T;

//// hash table with dependecies

System.Collections.Hashtable Dependencies = new System.Collections.Hashtable();

//// we need a dynamic array for storing parameter values

ArrayList reportParameterValues= new ArrayList();

if (reportCanBeRendered)

{

string deviceInfo;

string streamRoot;

Session["rs"] = rs;

streamRoot = ("getimage.aspx?report="+ (path + "&streamid="));

switch (format)

{

case "HTML4.0":

case "HTML3.2":

deviceInfo = "<DeviceInfo>" +

"<StreamRoot>http://ImagenesTemporales/</StreamRoot>" +

"<Toolbar>False</Toolbar>" +

"<Parameters>False</Parameters>" +

"<HTMLFragment>True</HTMLFragment>" +

"<StyleStream>False</StyleStream>" +

"<Section>0</Section>" +

"<Zoom>" +

"</Zoom>" +

"</DeviceInfo>";

break;

default:

deviceInfo = "<DeviceInfo></DeviceInfo>";

break;

}

// SQLRS-ReportViewer

if (!(reportParameterValues == null))

{

//reportParameterValues2 = reportParameterValues.ToArray(typeof(ParameterValue));

//reportParameterValues2 = (ParameterValue[])reportParameterValues.ToArray(typeof(ParameterValue));

}

DataSourceCredentials[] credentials = null;

string showHideToggle = null;

string encoding;

string mimeType;

string extension;

Warning[] warnings = null;

ParameterValue[] reportHistoryParameters = null;

string historyID = null;

string[] streamIDs = null;

ServerInfoHeader sh = new ServerInfoHeader();

rs.ServerInfoHeaderValue = sh;

byte[] result = null;

ParameterValue[] reportParameterValues2 = null;

result = rs.Render(format, deviceInfo, out extension, out mimeType, out encoding, out warnings, out streamIDs);

string encodingImage;

string mimeTypeImage;

byte[] image = rs.RenderStream("HTML4.0", streamIDs[0], null, out encodingImage,out mimeTypeImage);

System.IO.FileStream fs = System.IO.File.OpenWrite(@."C:\Inetpub\wwwroot\GescomDllo\ImagenesTemporales\" + streamIDs[0]);

fs.Write(image, 0, Convert.ToInt32(image.Length));

fs.Close();

// store ReportingServices and parameters object is session layer in case we need it for image streams

Session["rs"] = rs;

Session["reportParameterValues"] = reportParameterValues2;

switch (format)

{

case "HTML4.0":

case "HTML3.2":

System.Text.Encoding enc = System.Text.Encoding.UTF8;

// get the report as a string

string tmpReport = enc.GetString(result);

// replace all occurrences of report server link with current page link

tmpReport = tmpReport.Replace(reportServerURL.Replace("/ReportService.asmx", "?"), ("http://"

+ (Request["SERVER_NAME"]

+ (Request["SCRIPT_NAME"] + "?Report="))));

ReportPlaceholder.InnerHtml = tmpReport;

break;

default:

Response.ClearContent();

Response.AppendHeader("content-length", result.Length.ToString());

Response.ContentType = mimeType;

Response.BinaryWrite(result);

Response.Flush();

Response.Close();

break;

}

}

}

|||

Thanks buddy!!!

you answer helped me, though it was tough to figure out what i was doing wrong previosly. the only mistake i was doing is here .

it should be this.

image=rs.RenderStream("HTML4.0", streamID, null, out encodingImage, out mimeTypeImage);

i was doing this.

image=rs.RenderStream("IMAGE", streamID, null, out encodingImage, out mimeTypeImage);

Thanks again

|||

Luis Esteban, tendras ese mismo codigo pero para reporting services 2000?

Saludos

sql

Monday, March 12, 2012

Im getting a Login failed... error when trying to open my database from my default.aspx.vb

Good morning,

When I start my browser and try to open my (SQL Server 2000) database, using the 'Integrated Windows Authentication' method, I get the following error msg:
[SqlException: Login failed for user 'MYDOMAIN\ASPNET'.].

Where DOMAIN = MYDOMAIN
and USER = ASPNET
I have made this user known to the SQL Server 2000...

I opened my browser and executed the following function, which is in my default.aspx.vb file:

Public Function checkuser(ByVal userName As String, ByVal password As String) As Boolean
Dim strConnection As String = _
"Data Source=localhost;Initial Catalog=dbo; Integrated Security=True"
Dim sqlconQCards As SqlConnection = New SqlConnection(strConnection)
sqlconQCards.Open()
End Function

Rather than opening the database, the error message, shown above, is displayed.

I'd appreciate any help.

Thanks,
PatDid you add the user in the database itself ?!

Rudy|||Hi Rudy,

I finally got it to work by changing to 'SQL Server Authentication'. It requres that the user/pswd be supplied.

The 'Integrated Windows Authentication', which does not require the user/pswd, is not working for me...This is the Microsoft recommended method...

I am using Microsoft SQL Server 2000...

Thanks,
Pat