J
Jeff
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|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
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|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