Showing posts with label run. Show all posts
Showing posts with label run. Show all posts

Thursday, March 29, 2012

newbie: Instance failure!

Hey

asp.net 2.0

When I run the code below I get the runtime error "Instance Failure"

public static ICollection getInbox()
{
ArrayList al = new ArrayList();
ConnectionStringSettings css =
ConfigurationManager.ConnectionStrings["aspnet_DB"];
SqlDataSource sds = new SqlDataSource(css.ConnectionString, "SELECT
UserName from aspnet_Users");
try
{
IEnumerable INames = sds.Select(DataSourceSelectArguments.Empty);
foreach (DataRowView row in INames)
{
al.Add(row["UserName"]);
}
}
catch (SqlException sqlException)
{
Debug.WriteLine(sqlException.Message.ToString());
}
sds.Dispose();
return al;
}

The error occur at this line:
"IEnumerable INames = sds.Select(DataSourceSelectArguments.Empty);"

Just in case, here is a copy of my web.config file:
<?xml version="1.0"?>
<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
<appSettings>
</appSettings>
<connectionStrings>
<add name="aspnet_DB" connectionString="Data
Source=.\\SQLEXPRESS;Integrated
Security=True;AttachDBFilename=|DataDirectory|aspn etdb.mdf;User
Instance=true" />
</connectionStrings>
<system.web>
<roleManager enabled="true"/>
<authentication mode="Forms"/>
<compilation debug="true"/>
<profile enabled="true">
<properties>
<add name="Picture" type="System.Byte[]" />
<add name="PictureType" type="string" />
</properties>
</profile>
</system.web>
</configuration>

My gut feeling tells me it might be caused by the db connectionsting, but
I'm not sure... I'm trying to connect to the express database within the
project!

Any suggestions to what I should do to fix this?

Jeff"Jeff" <it_consultant1@.hotmail.com.NOSPAM> wrote in message
news:ueLDl0PnGHA.1444@.TK2MSFTNGP02.phx.gbl...
> Hey
>
> asp.net 2.0
>
> When I run the code below I get the runtime error "Instance Failure"
>
> public static ICollection getInbox()
> {
> ArrayList al = new ArrayList();
> ConnectionStringSettings css =
> ConfigurationManager.ConnectionStrings["aspnet_DB"];
> SqlDataSource sds = new SqlDataSource(css.ConnectionString, "SELECT
> UserName from aspnet_Users");
> try
> {
> IEnumerable INames = sds.Select(DataSourceSelectArguments.Empty);
> foreach (DataRowView row in INames)
> {
> al.Add(row["UserName"]);
> }
> }
> catch (SqlException sqlException)
> {
> Debug.WriteLine(sqlException.Message.ToString());
> }
> sds.Dispose();
> return al;
> }
>
> The error occur at this line:
> "IEnumerable INames = sds.Select(DataSourceSelectArguments.Empty);"
>
> Just in case, here is a copy of my web.config file:
> <?xml version="1.0"?>
> <configuration
> xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
> <appSettings>
> </appSettings>
> <connectionStrings>
> <add name="aspnet_DB" connectionString="Data
> Source=.\\SQLEXPRESS;Integrated
> Security=True;AttachDBFilename=|DataDirectory|aspn etdb.mdf;User
> Instance=true" />
> </connectionStrings>
> <system.web>
> <roleManager enabled="true"/>
> <authentication mode="Forms"/>
> <compilation debug="true"/>
> <profile enabled="true">
> <properties>
> <add name="Picture" type="System.Byte[]" />
> <add name="PictureType" type="string" />
> </properties>
> </profile>
> </system.web>
> </configuration>
>
> My gut feeling tells me it might be caused by the db connectionsting, but
> I'm not sure... I'm trying to connect to the express database within the
> project!
>
> Any suggestions to what I should do to fix this?
>
> Jeff
>

Monday, March 26, 2012

Newbie: problem posting

Hi All,

I've got the following .aspx file with the then following .cs code. The
page renders fine on first run, but once I click the submit, it just comes
back with a cannot be displayed page indicating that the page is not
available. Anyone see what probably obvious or stupid thing I'm missing?

TIA,

John

Test.aspx:
========

<%@dotnet.itags.org. Page Language="C#" src="http://pics.10026.com/?src=Temp.cs" Inherits="dgrdAccountSort" %>
<html>
<head>
</head>
<body>
<form runat="server">
<asp:datagrid id="grdAccount" runat="server" Height="100%"
Width="100%"></asp:datagrid>
<input type="submit" value="Submit Query" runat="server" />
</form>
</body>
</html
Temp.cs code:
==========
using System;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.OleDb;

public class dgrdAccountSort : Page
{
private string SortExpression;
protected DataGrid grdAccount;

protected void Page_Load(object Src, EventArgs e)
{
BindGridReader();
}

public void BindGridReader()
{
string SelectCommand = "SELECT * FROM AcctName";
if (SortExpression != null)
SelectCommand += " ORDER BY " + SortExpression;

OleDbConnection conn = new OleDbConnection(@dotnet.itags.org."Provider=vfpoledb.1;User
Id=;Password=;Data
Source=C:\temp\dotnet1.1\asp\essentials\samples\my testing\IntelligentOffice"
);
OleDbCommand cmd = new OleDbCommand( SelectCommand, conn );

conn.Open();
IDataReader reader = cmd.ExecuteReader();
grdAccount.DataSource = reader;
grdAccount.DataBind();

conn.Dispose();
}
}John,

Instead of Connection.Dispose();

Use Connection.Close(); and then Connection.Dispose() instead.

Connection.Dispose() tells the .Net garbage collector that it's okay to
dispose of an object when it gets around to it. It does not close the
connection.

Sincerely,

--
S. Justin Gengo, MCP
Web Developer

Free code library at:
www.aboutfortunate.com

"Out of chaos comes order."
Nietzche

"John Spiegel" <jspiegel@.c-comld.com> wrote in message
news:uoAcTxzaDHA.652@.tk2msftngp13.phx.gbl...
> Hi All,
> I've got the following .aspx file with the then following .cs code. The
> page renders fine on first run, but once I click the submit, it just comes
> back with a cannot be displayed page indicating that the page is not
> available. Anyone see what probably obvious or stupid thing I'm missing?
> TIA,
> John
> Test.aspx:
> ========
> <%@. Page Language="C#" src="http://pics.10026.com/?src=Temp.cs" Inherits="dgrdAccountSort" %>
> <html>
> <head>
> </head>
> <body>
> <form runat="server">
> <asp:datagrid id="grdAccount" runat="server" Height="100%"
> Width="100%"></asp:datagrid>
> <input type="submit" value="Submit Query" runat="server" />
> </form>
> </body>
> </html>
>
> Temp.cs code:
> ==========
> using System;
> using System.Web;
> using System.Web.UI;
> using System.Web.UI.WebControls;
> using System.Data;
> using System.Data.OleDb;
> public class dgrdAccountSort : Page
> {
> private string SortExpression;
> protected DataGrid grdAccount;
> protected void Page_Load(object Src, EventArgs e)
> {
> BindGridReader();
> }
>
> public void BindGridReader()
> {
> string SelectCommand = "SELECT * FROM AcctName";
> if (SortExpression != null)
> SelectCommand += " ORDER BY " + SortExpression;
> OleDbConnection conn = new OleDbConnection(@."Provider=vfpoledb.1;User
> Id=;Password=;Data
Source=C:\temp\dotnet1.1\asp\essentials\samples\my testing\IntelligentOffice"
> );
> OleDbCommand cmd = new OleDbCommand( SelectCommand, conn );
> conn.Open();
> IDataReader reader = cmd.ExecuteReader();
> grdAccount.DataSource = reader;
> grdAccount.DataBind();
> conn.Dispose();
> }
> }
Just a thought - have you tried closing the connection by setting the
commandbehavior of your command to do so after the Datareader is closed. And
then close the datareader after binding?

"John Spiegel" <jspiegel@.c-comld.com> wrote in message
news:uoAcTxzaDHA.652@.tk2msftngp13.phx.gbl...
> Hi All,
> I've got the following .aspx file with the then following .cs code. The
> page renders fine on first run, but once I click the submit, it just comes
> back with a cannot be displayed page indicating that the page is not
> available. Anyone see what probably obvious or stupid thing I'm missing?
> TIA,
> John
> Test.aspx:
> ========
> <%@. Page Language="C#" src="http://pics.10026.com/?src=Temp.cs" Inherits="dgrdAccountSort" %>
> <html>
> <head>
> </head>
> <body>
> <form runat="server">
> <asp:datagrid id="grdAccount" runat="server" Height="100%"
> Width="100%"></asp:datagrid>
> <input type="submit" value="Submit Query" runat="server" />
> </form>
> </body>
> </html>
>
> Temp.cs code:
> ==========
> using System;
> using System.Web;
> using System.Web.UI;
> using System.Web.UI.WebControls;
> using System.Data;
> using System.Data.OleDb;
> public class dgrdAccountSort : Page
> {
> private string SortExpression;
> protected DataGrid grdAccount;
> protected void Page_Load(object Src, EventArgs e)
> {
> BindGridReader();
> }
>
> public void BindGridReader()
> {
> string SelectCommand = "SELECT * FROM AcctName";
> if (SortExpression != null)
> SelectCommand += " ORDER BY " + SortExpression;
> OleDbConnection conn = new OleDbConnection(@."Provider=vfpoledb.1;User
> Id=;Password=;Data
Source=C:\temp\dotnet1.1\asp\essentials\samples\my testing\IntelligentOffice"
> );
> OleDbCommand cmd = new OleDbCommand( SelectCommand, conn );
> conn.Open();
> IDataReader reader = cmd.ExecuteReader();
> grdAccount.DataSource = reader;
> grdAccount.DataBind();
> conn.Dispose();
> }
> }
Just a thought - have you tried closing the connection by setting the
commandbehavior of your command to do so after the Datareader is closed. And
then close the datareader after binding?

"John Spiegel" <jspiegel@.c-comld.com> wrote in message
news:uoAcTxzaDHA.652@.tk2msftngp13.phx.gbl...
> Hi All,
> I've got the following .aspx file with the then following .cs code. The
> page renders fine on first run, but once I click the submit, it just comes
> back with a cannot be displayed page indicating that the page is not
> available. Anyone see what probably obvious or stupid thing I'm missing?
> TIA,
> John
> Test.aspx:
> ========
> <%@. Page Language="C#" src="http://pics.10026.com/?src=Temp.cs" Inherits="dgrdAccountSort" %>
> <html>
> <head>
> </head>
> <body>
> <form runat="server">
> <asp:datagrid id="grdAccount" runat="server" Height="100%"
> Width="100%"></asp:datagrid>
> <input type="submit" value="Submit Query" runat="server" />
> </form>
> </body>
> </html>
>
> Temp.cs code:
> ==========
> using System;
> using System.Web;
> using System.Web.UI;
> using System.Web.UI.WebControls;
> using System.Data;
> using System.Data.OleDb;
> public class dgrdAccountSort : Page
> {
> private string SortExpression;
> protected DataGrid grdAccount;
> protected void Page_Load(object Src, EventArgs e)
> {
> BindGridReader();
> }
>
> public void BindGridReader()
> {
> string SelectCommand = "SELECT * FROM AcctName";
> if (SortExpression != null)
> SelectCommand += " ORDER BY " + SortExpression;
> OleDbConnection conn = new OleDbConnection(@."Provider=vfpoledb.1;User
> Id=;Password=;Data
Source=C:\temp\dotnet1.1\asp\essentials\samples\my testing\IntelligentOffice"
> );
> OleDbCommand cmd = new OleDbCommand( SelectCommand, conn );
> conn.Open();
> IDataReader reader = cmd.ExecuteReader();
> grdAccount.DataSource = reader;
> grdAccount.DataBind();
> conn.Dispose();
> }
> }
John,

Sorry, but that was the only thing I could see that might have been wrong
with your code...

That said, I mostly program in VB.Net so maybe someone with more C#
experience could spot something else to try.

Good luck with it!

Sincerely,

--
S. Justin Gengo, MCP
Web Developer

Free code library at:
www.aboutfortunate.com

"Out of chaos comes order."
Nietzche

"John Spiegel" <jspiegel@.c-comld.com> wrote in message
news:e1doDH0aDHA.1280@.tk2msftngp13.phx.gbl...
> Thanks for getting involved! Unfortunately, I inserted a conn.Close()
> before the conn.Dispose() and it appears to do the same thing (work first
> time then die the second).
> FWIW, I'm using WebMatrix, the 1.1 version of .NET framework on a Win2K
pro
> machine.
> - John
> "S. Justin Gengo" <sjgengo@.aboutfortunate.com> wrote in message
> news:#wLKf6zaDHA.388@.TK2MSFTNGP10.phx.gbl...
> > John,
> > Instead of Connection.Dispose();
> > Use Connection.Close(); and then Connection.Dispose() instead.
> > Connection.Dispose() tells the .Net garbage collector that it's okay to
> > dispose of an object when it gets around to it. It does not close the
> > connection.
> > Sincerely,
> > --
> > S. Justin Gengo, MCP
> > Web Developer
> > Free code library at:
> > www.aboutfortunate.com
> > "Out of chaos comes order."
> > Nietzche
> > "John Spiegel" <jspiegel@.c-comld.com> wrote in message
> > news:uoAcTxzaDHA.652@.tk2msftngp13.phx.gbl...
> > > Hi All,
> > > > I've got the following .aspx file with the then following .cs code.
The
> > > page renders fine on first run, but once I click the submit, it just
> comes
> > > back with a cannot be displayed page indicating that the page is not
> > > available. Anyone see what probably obvious or stupid thing I'm
> missing?
> > > > TIA,
> > > > John
> > > > Test.aspx:
> > > ========
> > > > <%@. Page Language="C#" src="http://pics.10026.com/?src=Temp.cs" Inherits="dgrdAccountSort" %>
> > > <html>
> > > <head>
> > > </head>
> > > <body>
> > > <form runat="server">
> > > <asp:datagrid id="grdAccount" runat="server" Height="100%"
> > > Width="100%"></asp:datagrid>
> > > <input type="submit" value="Submit Query" runat="server" />
> > > </form>
> > > </body>
> > > </html>
> > > > > Temp.cs code:
> > > ==========
> > > using System;
> > > using System.Web;
> > > using System.Web.UI;
> > > using System.Web.UI.WebControls;
> > > using System.Data;
> > > using System.Data.OleDb;
> > > > public class dgrdAccountSort : Page
> > > {
> > > private string SortExpression;
> > > protected DataGrid grdAccount;
> > > > protected void Page_Load(object Src, EventArgs e)
> > > {
> > > BindGridReader();
> > > }
> > > > > public void BindGridReader()
> > > {
> > > string SelectCommand = "SELECT * FROM AcctName";
> > > if (SortExpression != null)
> > > SelectCommand += " ORDER BY " + SortExpression;
> > > > OleDbConnection conn = new
OleDbConnection(@."Provider=vfpoledb.1;User
> > > Id=;Password=;Data
> Source=C:\temp\dotnet1.1\asp\essentials\samples\my testing\IntelligentOffice"
> > > );
> > > OleDbCommand cmd = new OleDbCommand( SelectCommand, conn );
> > > > conn.Open();
> > > IDataReader reader = cmd.ExecuteReader();
> > > grdAccount.DataSource = reader;
> > > grdAccount.DataBind();
> > > > conn.Dispose();
> > > }
> > > }
> >
John,

Sorry, but that was the only thing I could see that might have been wrong
with your code...

That said, I mostly program in VB.Net so maybe someone with more C#
experience could spot something else to try.

Good luck with it!

Sincerely,

--
S. Justin Gengo, MCP
Web Developer

Free code library at:
www.aboutfortunate.com

"Out of chaos comes order."
Nietzche

"John Spiegel" <jspiegel@.c-comld.com> wrote in message
news:e1doDH0aDHA.1280@.tk2msftngp13.phx.gbl...
> Thanks for getting involved! Unfortunately, I inserted a conn.Close()
> before the conn.Dispose() and it appears to do the same thing (work first
> time then die the second).
> FWIW, I'm using WebMatrix, the 1.1 version of .NET framework on a Win2K
pro
> machine.
> - John
> "S. Justin Gengo" <sjgengo@.aboutfortunate.com> wrote in message
> news:#wLKf6zaDHA.388@.TK2MSFTNGP10.phx.gbl...
> > John,
> > Instead of Connection.Dispose();
> > Use Connection.Close(); and then Connection.Dispose() instead.
> > Connection.Dispose() tells the .Net garbage collector that it's okay to
> > dispose of an object when it gets around to it. It does not close the
> > connection.
> > Sincerely,
> > --
> > S. Justin Gengo, MCP
> > Web Developer
> > Free code library at:
> > www.aboutfortunate.com
> > "Out of chaos comes order."
> > Nietzche
> > "John Spiegel" <jspiegel@.c-comld.com> wrote in message
> > news:uoAcTxzaDHA.652@.tk2msftngp13.phx.gbl...
> > > Hi All,
> > > > I've got the following .aspx file with the then following .cs code.
The
> > > page renders fine on first run, but once I click the submit, it just
> comes
> > > back with a cannot be displayed page indicating that the page is not
> > > available. Anyone see what probably obvious or stupid thing I'm
> missing?
> > > > TIA,
> > > > John
> > > > Test.aspx:
> > > ========
> > > > <%@. Page Language="C#" src="http://pics.10026.com/?src=Temp.cs" Inherits="dgrdAccountSort" %>
> > > <html>
> > > <head>
> > > </head>
> > > <body>
> > > <form runat="server">
> > > <asp:datagrid id="grdAccount" runat="server" Height="100%"
> > > Width="100%"></asp:datagrid>
> > > <input type="submit" value="Submit Query" runat="server" />
> > > </form>
> > > </body>
> > > </html>
> > > > > Temp.cs code:
> > > ==========
> > > using System;
> > > using System.Web;
> > > using System.Web.UI;
> > > using System.Web.UI.WebControls;
> > > using System.Data;
> > > using System.Data.OleDb;
> > > > public class dgrdAccountSort : Page
> > > {
> > > private string SortExpression;
> > > protected DataGrid grdAccount;
> > > > protected void Page_Load(object Src, EventArgs e)
> > > {
> > > BindGridReader();
> > > }
> > > > > public void BindGridReader()
> > > {
> > > string SelectCommand = "SELECT * FROM AcctName";
> > > if (SortExpression != null)
> > > SelectCommand += " ORDER BY " + SortExpression;
> > > > OleDbConnection conn = new
OleDbConnection(@."Provider=vfpoledb.1;User
> > > Id=;Password=;Data
> Source=C:\temp\dotnet1.1\asp\essentials\samples\my testing\IntelligentOffice"
> > > );
> > > OleDbCommand cmd = new OleDbCommand( SelectCommand, conn );
> > > > conn.Open();
> > > IDataReader reader = cmd.ExecuteReader();
> > > grdAccount.DataSource = reader;
> > > grdAccount.DataBind();
> > > > conn.Dispose();
> > > }
> > > }
> >
Not yet, I'll give it a shot! I did find some very similar code code that
is working so I can use it to find my mistake. Thanks for the advice, Rick!

- John

"Rick Spiewak" <rickspiewak@.mindspring.com> wrote in message
news:#uNhx04aDHA.2436@.TK2MSFTNGP12.phx.gbl...
> Just a thought - have you tried closing the connection by setting the
> commandbehavior of your command to do so after the Datareader is closed.
And
> then close the datareader after binding?
> "John Spiegel" <jspiegel@.c-comld.com> wrote in message
> news:uoAcTxzaDHA.652@.tk2msftngp13.phx.gbl...
> > Hi All,
> > I've got the following .aspx file with the then following .cs code. The
> > page renders fine on first run, but once I click the submit, it just
comes
> > back with a cannot be displayed page indicating that the page is not
> > available. Anyone see what probably obvious or stupid thing I'm
missing?
> > TIA,
> > John
> > Test.aspx:
> > ========
> > <%@. Page Language="C#" src="http://pics.10026.com/?src=Temp.cs" Inherits="dgrdAccountSort" %>
> > <html>
> > <head>
> > </head>
> > <body>
> > <form runat="server">
> > <asp:datagrid id="grdAccount" runat="server" Height="100%"
> > Width="100%"></asp:datagrid>
> > <input type="submit" value="Submit Query" runat="server" />
> > </form>
> > </body>
> > </html>
> > Temp.cs code:
> > ==========
> > using System;
> > using System.Web;
> > using System.Web.UI;
> > using System.Web.UI.WebControls;
> > using System.Data;
> > using System.Data.OleDb;
> > public class dgrdAccountSort : Page
> > {
> > private string SortExpression;
> > protected DataGrid grdAccount;
> > protected void Page_Load(object Src, EventArgs e)
> > {
> > BindGridReader();
> > }
> > public void BindGridReader()
> > {
> > string SelectCommand = "SELECT * FROM AcctName";
> > if (SortExpression != null)
> > SelectCommand += " ORDER BY " + SortExpression;
> > OleDbConnection conn = new OleDbConnection(@."Provider=vfpoledb.1;User
> > Id=;Password=;Data
Source=C:\temp\dotnet1.1\asp\essentials\samples\my testing\IntelligentOffice"
> > );
> > OleDbCommand cmd = new OleDbCommand( SelectCommand, conn );
> > conn.Open();
> > IDataReader reader = cmd.ExecuteReader();
> > grdAccount.DataSource = reader;
> > grdAccount.DataBind();
> > conn.Dispose();
> > }
> > }
Not yet, I'll give it a shot! I did find some very similar code code that
is working so I can use it to find my mistake. Thanks for the advice, Rick!

- John

"Rick Spiewak" <rickspiewak@.mindspring.com> wrote in message
news:#uNhx04aDHA.2436@.TK2MSFTNGP12.phx.gbl...
> Just a thought - have you tried closing the connection by setting the
> commandbehavior of your command to do so after the Datareader is closed.
And
> then close the datareader after binding?
> "John Spiegel" <jspiegel@.c-comld.com> wrote in message
> news:uoAcTxzaDHA.652@.tk2msftngp13.phx.gbl...
> > Hi All,
> > I've got the following .aspx file with the then following .cs code. The
> > page renders fine on first run, but once I click the submit, it just
comes
> > back with a cannot be displayed page indicating that the page is not
> > available. Anyone see what probably obvious or stupid thing I'm
missing?
> > TIA,
> > John
> > Test.aspx:
> > ========
> > <%@. Page Language="C#" src="http://pics.10026.com/?src=Temp.cs" Inherits="dgrdAccountSort" %>
> > <html>
> > <head>
> > </head>
> > <body>
> > <form runat="server">
> > <asp:datagrid id="grdAccount" runat="server" Height="100%"
> > Width="100%"></asp:datagrid>
> > <input type="submit" value="Submit Query" runat="server" />
> > </form>
> > </body>
> > </html>
> > Temp.cs code:
> > ==========
> > using System;
> > using System.Web;
> > using System.Web.UI;
> > using System.Web.UI.WebControls;
> > using System.Data;
> > using System.Data.OleDb;
> > public class dgrdAccountSort : Page
> > {
> > private string SortExpression;
> > protected DataGrid grdAccount;
> > protected void Page_Load(object Src, EventArgs e)
> > {
> > BindGridReader();
> > }
> > public void BindGridReader()
> > {
> > string SelectCommand = "SELECT * FROM AcctName";
> > if (SortExpression != null)
> > SelectCommand += " ORDER BY " + SortExpression;
> > OleDbConnection conn = new OleDbConnection(@."Provider=vfpoledb.1;User
> > Id=;Password=;Data
Source=C:\temp\dotnet1.1\asp\essentials\samples\my testing\IntelligentOffice"
> > );
> > OleDbCommand cmd = new OleDbCommand( SelectCommand, conn );
> > conn.Open();
> > IDataReader reader = cmd.ExecuteReader();
> > grdAccount.DataSource = reader;
> > grdAccount.DataBind();
> > conn.Dispose();
> > }
> > }
I appreciate the time looking into it! It's been a long time since I've
picked up a new language so now I'm trying to basically do two at once!
Yea! <g
"S. Justin Gengo" <sjgengo@.aboutfortunate.com> wrote in message
news:#Xz3CQ6aDHA.2672@.tk2msftngp13.phx.gbl...
> John,
> Sorry, but that was the only thing I could see that might have been wrong
> with your code...
> That said, I mostly program in VB.Net so maybe someone with more C#
> experience could spot something else to try.
> Good luck with it!
> Sincerely,
> --
> S. Justin Gengo, MCP
> Web Developer
> Free code library at:
> www.aboutfortunate.com
> "Out of chaos comes order."
> Nietzche
>
> "John Spiegel" <jspiegel@.c-comld.com> wrote in message
> news:e1doDH0aDHA.1280@.tk2msftngp13.phx.gbl...
> > Thanks for getting involved! Unfortunately, I inserted a conn.Close()
> > before the conn.Dispose() and it appears to do the same thing (work
first
> > time then die the second).
> > FWIW, I'm using WebMatrix, the 1.1 version of .NET framework on a Win2K
> pro
> > machine.
> > - John
> > "S. Justin Gengo" <sjgengo@.aboutfortunate.com> wrote in message
> > news:#wLKf6zaDHA.388@.TK2MSFTNGP10.phx.gbl...
> > > John,
> > > > Instead of Connection.Dispose();
> > > > Use Connection.Close(); and then Connection.Dispose() instead.
> > > > Connection.Dispose() tells the .Net garbage collector that it's okay
to
> > > dispose of an object when it gets around to it. It does not close the
> > > connection.
> > > > Sincerely,
> > > > --
> > > S. Justin Gengo, MCP
> > > Web Developer
> > > > Free code library at:
> > > www.aboutfortunate.com
> > > > "Out of chaos comes order."
> > > Nietzche
> > > > > "John Spiegel" <jspiegel@.c-comld.com> wrote in message
> > > news:uoAcTxzaDHA.652@.tk2msftngp13.phx.gbl...
> > > > Hi All,
> > > > > > I've got the following .aspx file with the then following .cs code.
> The
> > > > page renders fine on first run, but once I click the submit, it just
> > comes
> > > > back with a cannot be displayed page indicating that the page is not
> > > > available. Anyone see what probably obvious or stupid thing I'm
> > missing?
> > > > > > TIA,
> > > > > > John
> > > > > > Test.aspx:
> > > > ========
> > > > > > <%@. Page Language="C#" src="http://pics.10026.com/?src=Temp.cs" Inherits="dgrdAccountSort" %>
> > > > <html>
> > > > <head>
> > > > </head>
> > > > <body>
> > > > <form runat="server">
> > > > <asp:datagrid id="grdAccount" runat="server" Height="100%"
> > > > Width="100%"></asp:datagrid>
> > > > <input type="submit" value="Submit Query" runat="server" />
> > > > </form>
> > > > </body>
> > > > </html>
> > > > > > > > Temp.cs code:
> > > > ==========
> > > > using System;
> > > > using System.Web;
> > > > using System.Web.UI;
> > > > using System.Web.UI.WebControls;
> > > > using System.Data;
> > > > using System.Data.OleDb;
> > > > > > public class dgrdAccountSort : Page
> > > > {
> > > > private string SortExpression;
> > > > protected DataGrid grdAccount;
> > > > > > protected void Page_Load(object Src, EventArgs e)
> > > > {
> > > > BindGridReader();
> > > > }
> > > > > > > > public void BindGridReader()
> > > > {
> > > > string SelectCommand = "SELECT * FROM AcctName";
> > > > if (SortExpression != null)
> > > > SelectCommand += " ORDER BY " + SortExpression;
> > > > > > OleDbConnection conn = new
> OleDbConnection(@."Provider=vfpoledb.1;User
> > > > Id=;Password=;Data
> > > Source=C:\temp\dotnet1.1\asp\essentials\samples\my testing\IntelligentOffice"
> > > > );
> > > > OleDbCommand cmd = new OleDbCommand( SelectCommand, conn );
> > > > > > conn.Open();
> > > > IDataReader reader = cmd.ExecuteReader();
> > > > grdAccount.DataSource = reader;
> > > > grdAccount.DataBind();
> > > > > > conn.Dispose();
> > > > }
> > > > }
> > > > > >
FYI, As it turns out, the error seems to be tied to my not limiting the
amount of the table it displayed on the page. Once I narrowed it down to 20
rows at a time, the error went away. I'm not clear as to whether that's a
configurable limitation or not.

- John

"John Spiegel" <jspiegel@.c-comld.com> wrote in message
news:uoAcTxzaDHA.652@.tk2msftngp13.phx.gbl...
> Hi All,
> I've got the following .aspx file with the then following .cs code. The
> page renders fine on first run, but once I click the submit, it just comes
> back with a cannot be displayed page indicating that the page is not
> available. Anyone see what probably obvious or stupid thing I'm missing?
> TIA,
> John
> Test.aspx:
> ========
> <%@. Page Language="C#" src="http://pics.10026.com/?src=Temp.cs" Inherits="dgrdAccountSort" %>
> <html>
> <head>
> </head>
> <body>
> <form runat="server">
> <asp:datagrid id="grdAccount" runat="server" Height="100%"
> Width="100%"></asp:datagrid>
> <input type="submit" value="Submit Query" runat="server" />
> </form>
> </body>
> </html>
>
> Temp.cs code:
> ==========
> using System;
> using System.Web;
> using System.Web.UI;
> using System.Web.UI.WebControls;
> using System.Data;
> using System.Data.OleDb;
> public class dgrdAccountSort : Page
> {
> private string SortExpression;
> protected DataGrid grdAccount;
> protected void Page_Load(object Src, EventArgs e)
> {
> BindGridReader();
> }
>
> public void BindGridReader()
> {
> string SelectCommand = "SELECT * FROM AcctName";
> if (SortExpression != null)
> SelectCommand += " ORDER BY " + SortExpression;
> OleDbConnection conn = new OleDbConnection(@."Provider=vfpoledb.1;User
> Id=;Password=;Data
Source=C:\temp\dotnet1.1\asp\essentials\samples\my testing\IntelligentOffice"
> );
> OleDbCommand cmd = new OleDbCommand( SelectCommand, conn );
> conn.Open();
> IDataReader reader = cmd.ExecuteReader();
> grdAccount.DataSource = reader;
> grdAccount.DataBind();
> conn.Dispose();
> }
> }

Saturday, March 24, 2012

newbie: runtime error

Hey
asp.net 2.0
When I run the code below I get a runtime error ("Object reference not set
to an instance of an object. "):
Here is the code:
public static ICollection getInbox()
{
ArrayList al = new ArrayList();
ConnectionStringSettings css =
ConfigurationManager.ConnectionStrings["aspnet_DB"];
SqlDataSource sds = new SqlDataSource(css.ConnectionString, "SELECT
UserName from aspnet_Users");
try
{
IEnumerable INames = sds.Select(DataSourceSelectArguments.Empty);
foreach (DataRowView row in INames)
{
al.Add(row["UserName"]);
}
}
catch (SqlException sqlException)
{
Debug.WriteLine(sqlException.Message.ToString());
}
sds.Dispose();
return al;
}
The error occur at this line in the code:
SqlDataSource sds = new SqlDataSource(css.ConnectionString, "SELECT
UserName from aspnet_Users");
Just in case here is my web.config file:
<?xml version="1.0"?>
<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
<appSettings>
<add key="aspnet_DB" value="Data Source=.\\SQLEXPRESS;Integrated
Security=True;AttachDBFilename=|DataDire
ctory|aspnetdb.mdf;User
Instance=true" />
</appSettings>
<system.web>
<roleManager enabled="true"/>
<authentication mode="Forms"/>
<compilation debug="true"/>
<profile enabled="true">
<properties>
<add name="Picture" type="System.Byte[]" />
<add name="PictureType" type="string" />
</properties>
</profile>
</system.web>
</configuration>
Any ideas what I'm doing wrong here?
JeffJeff wrote:
> Hey
> asp.net 2.0
>
> When I run the code below I get a runtime error ("Object reference not set
> to an instance of an object. "):
> Here is the code:
> public static ICollection getInbox()
> {
> ArrayList al = new ArrayList();
> ConnectionStringSettings css =
> ConfigurationManager.ConnectionStrings["aspnet_DB"];
> SqlDataSource sds = new SqlDataSource(css.ConnectionString, "SELECT
> UserName from aspnet_Users");
> try
> {
> IEnumerable INames = sds.Select(DataSourceSelectArguments.Empty);
> foreach (DataRowView row in INames)
> {
> al.Add(row["UserName"]);
> }
> }
> catch (SqlException sqlException)
> {
> Debug.WriteLine(sqlException.Message.ToString());
> }
> sds.Dispose();
> return al;
> }
> The error occur at this line in the code:
> SqlDataSource sds = new SqlDataSource(css.ConnectionString, "SELECT
> UserName from aspnet_Users");
> Just in case here is my web.config file:
> <?xml version="1.0"?>
> <configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0"
> <appSettings>
> <add key="aspnet_DB" value="Data Source=.\\SQLEXPRESS;Integrated
> Security=True;AttachDBFilename=|DataDire
ctory|aspnetdb.mdf;User
> Instance=true" />
> </appSettings>
> <system.web>
> <roleManager enabled="true"/>
> <authentication mode="Forms"/>
> <compilation debug="true"/>
> <profile enabled="true">
> <properties>
> <add name="Picture" type="System.Byte[]" />
> <add name="PictureType" type="string" />
> </properties>
> </profile>
> </system.web>
> </configuration>
> Any ideas what I'm doing wrong here?
> Jeff
Hi Jeff,
If looks like css is null. I'm guessing this is because there is no
<connectionStrings> in the web.config.
See http://www.devx.com/dotnet/Article/27562
David Hogue

newbie: runtime error

Hey

asp.net 2.0

When I run the code below I get a runtime error ("Object reference not set
to an instance of an object. "):

Here is the code:

public static ICollection getInbox()
{
ArrayList al = new ArrayList();
ConnectionStringSettings css =
ConfigurationManager.ConnectionStrings["aspnet_DB"];
SqlDataSource sds = new SqlDataSource(css.ConnectionString, "SELECT
UserName from aspnet_Users");
try
{
IEnumerable INames = sds.Select(DataSourceSelectArguments.Empty);
foreach (DataRowView row in INames)
{
al.Add(row["UserName"]);
}
}
catch (SqlException sqlException)
{
Debug.WriteLine(sqlException.Message.ToString());
}
sds.Dispose();
return al;
}

The error occur at this line in the code:
SqlDataSource sds = new SqlDataSource(css.ConnectionString, "SELECT
UserName from aspnet_Users");

Just in case here is my web.config file:
<?xml version="1.0"?>
<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
<appSettings>
<add key="aspnet_DB" value="Data Source=.\\SQLEXPRESS;Integrated
Security=True;AttachDBFilename=|DataDirectory|aspn etdb.mdf;User
Instance=true" />
</appSettings>
<system.web>
<roleManager enabled="true"/>
<authentication mode="Forms"/>
<compilation debug="true"/>
<profile enabled="true">
<properties>
<add name="Picture" type="System.Byte[]" />
<add name="PictureType" type="string" />
</properties>
</profile>
</system.web>
</configuration>

Any ideas what I'm doing wrong here?

JeffJeff wrote:
> Hey
>
> asp.net 2.0
>
>
> When I run the code below I get a runtime error ("Object reference not set
> to an instance of an object. "):
>
> Here is the code:
>
> public static ICollection getInbox()
> {
> ArrayList al = new ArrayList();
> ConnectionStringSettings css =
> ConfigurationManager.ConnectionStrings["aspnet_DB"];
> SqlDataSource sds = new SqlDataSource(css.ConnectionString, "SELECT
> UserName from aspnet_Users");
> try
> {
> IEnumerable INames = sds.Select(DataSourceSelectArguments.Empty);
> foreach (DataRowView row in INames)
> {
> al.Add(row["UserName"]);
> }
> }
> catch (SqlException sqlException)
> {
> Debug.WriteLine(sqlException.Message.ToString());
> }
> sds.Dispose();
> return al;
> }
>
> The error occur at this line in the code:
> SqlDataSource sds = new SqlDataSource(css.ConnectionString, "SELECT
> UserName from aspnet_Users");
>
> Just in case here is my web.config file:
> <?xml version="1.0"?>
> <configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
> <appSettings>
> <add key="aspnet_DB" value="Data Source=.\\SQLEXPRESS;Integrated
> Security=True;AttachDBFilename=|DataDirectory|aspn etdb.mdf;User
> Instance=true" />
> </appSettings>
> <system.web>
> <roleManager enabled="true"/>
> <authentication mode="Forms"/>
> <compilation debug="true"/>
> <profile enabled="true">
> <properties>
> <add name="Picture" type="System.Byte[]" />
> <add name="PictureType" type="string" />
> </properties>
> </profile>
> </system.web>
> </configuration>
>
> Any ideas what I'm doing wrong here?
>
> Jeff

Hi Jeff,

If looks like css is null. I'm guessing this is because there is no
<connectionStrings> in the web.config.

See http://www.devx.com/dotnet/Article/27562
--
David Hogue

newbie: running asp.bnet application

Hi,

I am trying to run an ASP.net application. What files do I need to keep in inteup and what files can I put anywhere else on my HDisk.??

Thanks,

Hello Bilalso,

I am not really sure what you mean but maybe this will help you out.

The files needed to run an ASP.NET application are all.aspx pages and the completebin folder. The codebehind files (.aspx.cs) are not necessary to run the application when it is compiled all codebehind code is stored in a.dll file which is stored in thebin folder. When you are using usercontrols you should also store the.ascx files and of course any third parties components should be included (usually in thebin folder).

You can store you're website anywhere on your hardrive as long as you configure IIS correctly. To do this create a virtual website under the Default website using the following steps:

- Open IIS
- Select the Default website and press the right mouse button
- Goto New -> Virtual website
- Submit an Alias for the Virual directory (can be anything you want)
- Now select the directory where your website is located on your harddrive
- Leave the access permissions as they are (unless you have special wishes)
- Hit the Finish button and you are ready

A hope this answers your question.

Cheers, Maurits


Hello:

You need to create a new website with either Visual Studio.NET, WebMatrix, Visual Web Express. They will create the website for you, in the wwwroot folder of the inetpub.

Have you installed .NET om your machine?

Regards

Newbie: Webservice String Function question

Why do i get this message when i try to run it as a webservice?
First "Name 'TRIM' is not declared." Then "Name 'REPLACE' is not declared."

This is the code i use:
<%@dotnet.itags.org. WebService language="VB" class="test" %
Imports System
Imports System.Web.Services
Imports System.Xml.Serialization

Public Class test

<WebMethod> Public Function Add(a As Integer, b As Integer) As Integer
Return a + b
End Function

<WebMethod> Public Function WebTrim(a As String) As string
Return TRIM(a)
End Function

<WebMethod> Public Function WebReplace(a As String) As string
Return REPLACE(a, "e", "f")
End Function

End Class

If i run is like a normal web page it works perfect.
I'm using Webmatrix and have reinstalled all met .net components.

Please help me.

Thanx in advancehave you tried the OO way?

return a.Trim()

return a.Replace("e","f")
Thanx for the quick repley but i found wath it is.
This one i missed:
Imports Microsoft.VisualBasic

Thursday, March 22, 2012

Newbie-Q: 403 Error

I'm just getting started with ASP.NET. I got a 403 error the first time I
tried to run a web site in VS 2005, so I did two things:
1) I confirmed that the IIS default web site was configured for anonymous
access in the MMC Authentication Methods dialog.
2) I gave the Internet Guest account read and write permissions on the
Inetpub\wwwroot folder.
Do I need to do anything else to configure ASP.NET for IIS or for NT file
access? Are there any articles that discuss this aspect of security? Thanks.I spoke too soon-- I'm still getting the 403 error

Newbie-Q: 403 Error

I'm just getting started with ASP.NET. I got a 403 error the first time I
tried to run a web site in VS 2005, so I did two things:

1) I confirmed that the IIS default web site was configured for anonymous
access in the MMC Authentication Methods dialog.

2) I gave the Internet Guest account read and write permissions on the
Inetpub\wwwroot folder.

Do I need to do anything else to configure ASP.NET for IIS or for NT file
access? Are there any articles that discuss this aspect of security? Thanks.I spoke too soon-- I'm still getting the 403 error

Friday, March 16, 2012

news website

I am going to run an website publishing news and article. I would like to be able to MANAGE articles accoring to their topic and time. I would like to know if :
1) Is there any software to do that work
2) Database can store short text ( at least what I have been working with, less than 60 characterBig Smile [:D]) but is it possible to store the whole article as an entry in database.
3) If both answer to 1 and 2 is NO, what is the common way that website like what I am intending to run would do.
Regards.

umala wrote:

2) Database can store short text ( at least what I have been working with, less than 60 characterBig Smile [:D]) but is it possible to store the whole article as an entry in database.


I'm not sure about software that will do this for you, but you can use a SQL Server database to store your articles depending on the length. Using the varchar datatype you can store anything from 1 to 8000 characters. If your articles will fit within this range, this would be the best solution because you can add columns for both topic and time or date, which you can then sort them through your database query.
Hope this helps somewhat,
smtraber