467,895 Members | 1,423 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 467,895 developers. It's quick & easy.

"Unable to connect to SQL Server database" error when using profile

Hello,

I'm using CreateUserWizard control in ASP.NET 2.0. I'm storing the data in
SQL Server 2005.

The first and last steps run smoothly without any problems. But I added one
middle step to collect some other information from the user. I've added this
to Web.config:

<profile>
<properties>
<add name="FirstName" />
<add name="LastName" />
<add name="Country" />
<add name="City" />
<add name="Email2" />
</properties>
</profile>

Then I try to collect this data:

Protected Sub cuzGudzon_FinishButtonClick(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.WizardNavigationEventArg s) Handles
cuzGudzon.FinishButtonClick
Try
With Profile
..FirstName = Me.txtFirstName.Text
..LastName = Me.txtLastName.Text
..Country = Me.txtCountry.Text
..City = Me.txtCity.Text
..Email2 = Me.txtEmail2.Text
End With
Catch ex As Exception
Me.lblError.Text = ex.Message
Finally
End Try
End Sub

This is where I get an error: Unable to connect to SQL Server database

Aparently, the connection string I specified in Web.config is correct, since
the first step where the user creates a user name and password runs without
any problems, and the data is entered into the database. Am I missing
something in this additional step?

I would appreciate your help.

Thank you,

--
Peter Afonin
Oct 8 '06 #1
  • viewed: 6076
Share:
2 Replies
Make sure you have set up the Profile to use the proper connection string.
Membership and Profile are two completely separate sections in the
web.config. Same is true for Roles. While this may seem counter intuitive,
the reason for this is flexibility, as you might want to include the default
membership, but custom profile and role providers. You can do this with a
simple config change (and code to support the custom elements, of course).

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA
http://gregorybeamer.spaces.live.com/

*************************************************
Think Outside the Box!
*************************************************
"Peter Afonin" <pa*****@hotmail.comwrote in message
news:ua**************@TK2MSFTNGP04.phx.gbl...
Hello,

I'm using CreateUserWizard control in ASP.NET 2.0. I'm storing the data in
SQL Server 2005.

The first and last steps run smoothly without any problems. But I added
one middle step to collect some other information from the user. I've
added this to Web.config:

<profile>
<properties>
<add name="FirstName" />
<add name="LastName" />
<add name="Country" />
<add name="City" />
<add name="Email2" />
</properties>
</profile>

Then I try to collect this data:

Protected Sub cuzGudzon_FinishButtonClick(ByVal sender As Object, ByVal e
As System.Web.UI.WebControls.WizardNavigationEventArg s) Handles
cuzGudzon.FinishButtonClick
Try
With Profile
.FirstName = Me.txtFirstName.Text
.LastName = Me.txtLastName.Text
.Country = Me.txtCountry.Text
.City = Me.txtCity.Text
.Email2 = Me.txtEmail2.Text
End With
Catch ex As Exception
Me.lblError.Text = ex.Message
Finally
End Try
End Sub

This is where I get an error: Unable to connect to SQL Server database

Aparently, the connection string I specified in Web.config is correct,
since the first step where the user creates a user name and password runs
without any problems, and the data is entered into the database. Am I
missing something in this additional step?

I would appreciate your help.

Thank you,

--
Peter Afonin

Oct 8 '06 #2
Thank you, Gregory,

This was a main problem - I couldn't find any example on how to do this.
Finally figured this out:

<profile defaultProvider="GudzonProfileProvider">
<providers>
<add name="GudzonProfileProvider"
type="System.Web.Profile.SqlProfileProvider" connectionStringName="Gudzon"/>
</providers>
<properties>
<add name="FirstName" />
<add name="LastName" />
<add name="Country" />
<add name="City" />
<add name="Email2" />
</properties>
</profile>

Peter

"Cowboy (Gregory A. Beamer)" <No************@comcast.netNoSpamMwrote in
message news:%2****************@TK2MSFTNGP04.phx.gbl...
Make sure you have set up the Profile to use the proper connection string.
Membership and Profile are two completely separate sections in the
web.config. Same is true for Roles. While this may seem counter intuitive,
the reason for this is flexibility, as you might want to include the
default membership, but custom profile and role providers. You can do this
with a simple config change (and code to support the custom elements, of
course).

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA
http://gregorybeamer.spaces.live.com/

*************************************************
Think Outside the Box!
*************************************************
"Peter Afonin" <pa*****@hotmail.comwrote in message
news:ua**************@TK2MSFTNGP04.phx.gbl...
>Hello,

I'm using CreateUserWizard control in ASP.NET 2.0. I'm storing the data
in SQL Server 2005.

The first and last steps run smoothly without any problems. But I added
one middle step to collect some other information from the user. I've
added this to Web.config:

<profile>
<properties>
<add name="FirstName" />
<add name="LastName" />
<add name="Country" />
<add name="City" />
<add name="Email2" />
</properties>
</profile>

Then I try to collect this data:

Protected Sub cuzGudzon_FinishButtonClick(ByVal sender As Object, ByVal e
As System.Web.UI.WebControls.WizardNavigationEventArg s) Handles
cuzGudzon.FinishButtonClick
Try
With Profile
.FirstName = Me.txtFirstName.Text
.LastName = Me.txtLastName.Text
.Country = Me.txtCountry.Text
.City = Me.txtCity.Text
.Email2 = Me.txtEmail2.Text
End With
Catch ex As Exception
Me.lblError.Text = ex.Message
Finally
End Try
End Sub

This is where I get an error: Unable to connect to SQL Server database

Aparently, the connection string I specified in Web.config is correct,
since the first step where the user creates a user name and password runs
without any problems, and the data is entered into the database. Am I
missing something in this additional step?

I would appreciate your help.

Thank you,

--
Peter Afonin


Oct 8 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by Bruce Schechter | last post: by
10 posts views Thread by VB Programmer | last post: by
2 posts views Thread by Andy Chen | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.