Solved

asp.net connection string value lost

Posted on 2007-12-03
7
160 Views
Last Modified: 2013-11-07
I setup my connection string in my web.config.

I have a custom membership provider that defines it in the initialize....
connStr = config("connectionString")

When I call the validateuser(), it hits the connection string okay.

I call the exact same code in my GetUser(), and now my connection string is empty.

both have these at the top:
        Using conn As New SqlConnection(connStr)

What is happening? Why is it now empty for this function?
thanks.
0
Comment
Question by:Starr Duskk
  • 6
7 Comments
 
LVL 15

Accepted Solution

by:
spprivate earned 500 total points
ID: 20398618
connStr = config("connectionString")
I assume this connstr variable scope is not public or class level.You would have declared it in a method level and hence you are not getting the value.
Declare the connStr initialization on a class level and then use it.
0
 
LVL 2

Author Comment

by:Starr Duskk
ID: 20398755
It IS class level:

Public Class CustomMembershipProvider
    Inherits MembershipProvider

    Private connStr As String
    Private comm As New SqlClient.SqlCommand
0
 
LVL 2

Author Comment

by:Starr Duskk
ID: 20398816
I declared it Public and that didn't fix it either.

I do notice stepping through it, that the Initialize is not called on the GetUser. It is called on the ValidateUser, but not the GetUser....

???
0
Space-Age Communications Transitions to DevOps

ViaSat, a global provider of satellite and wireless communications, securely connects businesses, governments, and organizations to the Internet. Learn how ViaSat’s Network Solutions Engineer, drove the transition from a traditional network support to a DevOps-centric model.

 
LVL 2

Author Comment

by:Starr Duskk
ID: 20398842
I take that back. When I log in, it hits the validateuser, but putting a breakpoint on the initialize, I never see it hit that.

Although, the ValidateUser does have a valid connstr.
0
 
LVL 2

Author Comment

by:Starr Duskk
ID: 20398875
Hmmm. I have old backup copies that are hitting the initialize on log in when I debug, but my latest version is not.

What could be the reason?
thanks.
0
 
LVL 2

Author Comment

by:Starr Duskk
ID: 20398898
Okay, I notice that when I put code to call my getuser in my pre_init on my master page, it never hits the initialize. I'll have to look at that.

Meanwhile, if anyone has any thoughts, would appreciate it.

thanks.
0
 
LVL 2

Author Comment

by:Starr Duskk
ID: 20398987
I need to create a new question on this.

My problem is that my initialize is not firing. So I need to ask about that.

thanks.
0

Featured Post

Resolve Critical IT Incidents Fast

If your data, services or processes become compromised, your organization can suffer damage in just minutes and how fast you communicate during a major IT incident is everything. Learn how to immediately identify incidents & best practices to resolve them quickly and effectively.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
.NET 2008 VB and C# 6 39
parsing JSON help 1 20
jquery tab header text 1 23
How to extract certain lines from textfile and save them to another file? 6 27
Welcome my friends to the second instalment and follow-up to our Minify and Concatenate Your Scripts and Stylesheets (http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/A_4334-Minify-and-Concatenate-Your-Scripts-and-Stylesheets.html)…
This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question