newbie: problems with Profile.Providers

J

Jeff

hey

asp.net 2.0

I want to search for 1 specific profile in my code. So I'm trying to use the
FindProfileByUserName method.
But before I use that method I must establish a provider object that can
call this method...

Here is part of my code:
String username = Request.QueryString["USERNAME"];
int totalProfiles;
SqlProfileProvider provider = (SqlProfileProvider)
Profile.Providers["SqlProvider"];
ProfileInfoCollection profiles =
provider.FindProfilesByUserName(ProfileAuthenticationOption.Authenticated,
username, 0, 1, out totalProfiles);

Much of this code is taken from the MSDN documentaion. my problem is that
this line don't work:
SqlProfileProvider provider = (SqlProfileProvider)
Profile.Providers["SqlProvider"];
The "provider" variable is still null after that line is executed, this
causes my code to crash... maybe it's a bad idea of my to specify provider
to be of the SqlProfileProvider class?

Here is 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" />
providerName="System.Data.SqlClient" />
</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>


Any suggestions to what causes 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,996
Messages
2,570,238
Members
46,826
Latest member
robinsontor

Latest Threads

Top