newbie: Instance failure!

J

Jeff

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|aspnetdb.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
 
J

Jeff

Jeff said:
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|aspnetdb.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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,070
Latest member
BiogenixGummies

Latest Threads

Top