Showing posts with label control. Show all posts
Showing posts with label control. Show all posts

Thursday, March 22, 2012

cant access the datasource control

When I put a sqldatasource in my page and want to configure it and add a new connection to it I recieve this error : "object reference not set to an instance of an object" . Do you have any idea about solving this problem. please help me Thanks

Hi,

when asking a question about code or when you get an error always try to provide therelevant pieces of code and the error message that you get. This helps the people around here to better help you out.

Grz, Kris.

|||

My program has only a simple datagrid that should get data from a sql table and show it.This is only a test after changing the IIS settings. You can see my code here:

When I run this program I don't recieve any error but the explorer shows the blank page. When I try making connectionstring via sqldatasource I recieve that error:"the object reference...".thanks for helping

public

partialclassado1 : System.Web.UI.Page

{

privatevoid bindgrid()

{

string conStr ="Data Source=.;Initial Catalog=Northwind;Persist Security Info=True;User ID=sa";SqlConnection conn =newSqlConnection(conStr);// Open the connection

conn.Open();

// Create a data adapter objectSqlDataAdapter adapter =newSqlDataAdapter("SELECT * FROM testt", conn);DataSet ds =newDataSet();

adapter.Fill(ds);

GridView1.DataBind();

conn.Close();

}

protectedvoid Page_Load(object sender,EventArgs e)

{

if (!IsPostBack)

{

bindgrid();

}}}

///////////////////////////////

the body of aspx file is here:

<

body><formid="form1"runat="server"><div> <asp:SqlDataSourceID="SqlDataSource1"runat="server"></asp:SqlDataSource><asp:GridViewID="GridView1"runat="server"></asp:GridView></div></form>

</

body>

/////////////////////////////////////

|||

Hi,

hsharifi:

publicpartialclassado1 : System.Web.UI.Page

{

privatevoid bindgrid()

{

string conStr ="Data Source=.;Initial Catalog=Northwind;Persist Security Info=True;User ID=sa";

SqlConnection conn =newSqlConnection(conStr);

// Open the connection

conn.Open();

// Create a data adapter objectSqlDataAdapter adapter =newSqlDataAdapter("SELECT * FROM testt", conn);DataSet ds =newDataSet();

adapter.Fill(ds);

GridView1.DataBind();

conn.Close();

}

protectedvoid Page_Load(object sender,EventArgs e)

{

if (!IsPostBack)

{

bindgrid();

}}}

///////////////////////////////

the body of aspx file is here:

<

body><formid="form1"runat="server"><div> <asp:SqlDataSourceID="SqlDataSource1"runat="server"></asp:SqlDataSource><asp:GridViewID="GridView1"runat="server"></asp:GridView></div></form>

</

body>

/////////////////////////////////////

it seems like you're trying to do 2 things here: you want to use code & the SqlDataSource control together, that's a no go.

Get rid of the SqlDataSource control on your page and in the codefile, just before you call the DataBind() method place this line:

GridView1.DataSource = ds;
GridView1.DataBind();

Grz, Kris.

|||

Hi Xlll ,and thank you for replying me.

I did the thing that you said but my problem is still going on. After running my program the browser shows a blank page. I had to change many settings in IIS, do you think this problem is related to these changes or may be I should reinstall vs.net after that.

I would be glad to hear your opinion. Thanks

|||

Hi,

before re?nstalling you can first let the aspnet_regiis -i tool do its work to set the correct settings for the correct framework in IIS.

Something else that you can try: place a TextBox, Button and Label control on a webform. In the Button Click event you place this code:

Label1.Text = TextBox1.Text

and see if it executes well on your server. It's probably something stupid but I like to use such scenario's to quickly test out if ASP.NET is installed properly on a machine.

Grz, Kris.

Sunday, March 11, 2012

Cannot view actual report

Hi,

I am using the reportviewer control the following way

<%@. Page Language="C#" AutoEventWireup="true" CodeFile="RenderReport.aspx.cs" Inherits="pages_RenderReport" Title="View Report"%>

<%@. Register Assembly="Microsoft.ReportViewer.WebForms, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"

Namespace="Microsoft.Reporting.WebForms" TagPrefix="rsweb" %>

<html runat="server">

<head runat=server></head>

<body>

<form runat=server>

<table width="100%" cellpadding=0 cellspacing=0 border=0>

<tr>

<td valign="top" id="report" width="100%" style="height: 104%">

<rsweb:ReportViewer ID="reportViewer" runat="server" Width=100% SizeToReportContent=false BorderWidth="1pt" ExportContentDisposition="AlwaysInline" AsyncRendering="False" Height="600px" Font-Size=Small ShowParameterPrompts=true ShowPageNavigationControls=true ProcessingMode="Remote">

</rsweb:ReportViewer>

</td>

</tr>

</table>

</form>

</body>

</html>

I cannot see the report at all?..All i see is the parameters area.

thanks.

It doesn't appear that you specified a report to render. The Report Viewer control won't render anything unless it's given a report.

-Albert

|||

Actually i had set the report in the code. I should have included that code in this forum. I however figured out the problem.

Thanks.

Cannot view actual report

Hi,

I am using the reportviewer control the following way

<%@. Page Language="C#" AutoEventWireup="true" CodeFile="RenderReport.aspx.cs" Inherits="pages_RenderReport" Title="View Report"%>

<%@. Register Assembly="Microsoft.ReportViewer.WebForms, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"

Namespace="Microsoft.Reporting.WebForms" TagPrefix="rsweb" %>

<html runat="server">

<head runat=server></head>

<body>

<form runat=server>

<table width="100%" cellpadding=0 cellspacing=0 border=0>

<tr>

<td valign="top" id="report" width="100%" style="height: 104%">

<rsweb:ReportViewer ID="reportViewer" runat="server" Width=100% SizeToReportContent=false BorderWidth="1pt" ExportContentDisposition="AlwaysInline" AsyncRendering="False" Height="600px" Font-Size=Small ShowParameterPrompts=true ShowPageNavigationControls=true ProcessingMode="Remote">

</rsweb:ReportViewer>

</td>

</tr>

</table>

</form>

</body>

</html>

I cannot see the report at all?..All i see is the parameters area.

thanks.

It doesn't appear that you specified a report to render. The Report Viewer control won't render anything unless it's given a report.

-Albert

|||

Actually i had set the report in the code. I should have included that code in this forum. I however figured out the problem.

Thanks.

Wednesday, March 7, 2012

Cannot start SQL Services; Getting error 1053

MSSQLSERVICE will not start. I am getting "Error 1053: The service did not respond to the start or control request in a timely fashion" and "Timeout 30000 milliseconds waiting for the MSSQLSERVER service to connect".
The server was working fine until it was moved from our development rack to our production rack. This error occurs after reboots, and after trying to use the Local System account and domain accounts that are local administrators to the machine.
Anyone have any ideas?
Thanks
"Racer-D" <Racer-D@.discussions.microsoft.com> wrote in message
news:B7C1C5EB-7B29-42B3-A607-0860221CE77F@.microsoft.com...
> MSSQLSERVICE will not start. I am getting "Error 1053: The service did
not respond to the start or control request in a timely fashion" and
"Timeout 30000 milliseconds waiting for the MSSQLSERVER service to connect".
> The server was working fine until it was moved from our development rack
to our production rack. This error occurs after reboots, and after trying
to use the Local System account and domain accounts that are local
administrators to the machine.
> Anyone have any ideas?
This article specifically points to issues with the sql server agent, but it
may be relevant, especially with regard to the permissions issue.
http://support.microsoft.com/default...&Product=sql2k
Any chance the server was renamed, or moved from one domain to another
domain?
Steve

Cannot start SQL Services; Getting error 1053

MSSQLSERVICE will not start. I am getting "Error 1053: The service did not
respond to the start or control request in a timely fashion" and "Timeout 30
000 milliseconds waiting for the MSSQLSERVER service to connect".
The server was working fine until it was moved from our development rack to
our production rack. This error occurs after reboots, and after trying to u
se the Local System account and domain accounts that are local administrator
s to the machine.
Anyone have any ideas?
Thanks"Racer-D" <Racer-D@.discussions.microsoft.com> wrote in message
news:B7C1C5EB-7B29-42B3-A607-0860221CE77F@.microsoft.com...
> MSSQLSERVICE will not start. I am getting "Error 1053: The service did
not respond to the start or control request in a timely fashion" and
"Timeout 30000 milliseconds waiting for the MSSQLSERVER service to connect".
> The server was working fine until it was moved from our development rack
to our production rack. This error occurs after reboots, and after trying
to use the Local System account and domain accounts that are local
administrators to the machine.
> Anyone have any ideas?
This article specifically points to issues with the sql server agent, but it
may be relevant, especially with regard to the permissions issue.
http://support.microsoft.com/defaul...0&Product=sql2k
Any chance the server was renamed, or moved from one domain to another
domain?
Steve