Connection String can't be blank..

Last post 05-16-2008 4:19 PM by griff303. 4 replies.

Sort Posts:

  • Connection String can't be blank..

    05-16-2008, 2:30 PM
    • Loading...
    • griff303
    • Joined on 02-03-2004, 11:53 AM
    • Posts 652

    I'm finishing up my customer membership provider and seem to be stuck on this error that I have thrown. It doesn't seem to be grabbing the connection string properly. I have rebuilt the provider several times to no avail. Is there anything special I am missing. I have tried to login, but the ProviderException is thrown every time. Don't mind the names, I removed the company name from them.

     

    Web.config

    1    <membership defaultProvider="MembershipProvider">
    2          <providers>
    3            <clear />
    4            <add name="StaplesMemberShipProvider" 
    5                type="MemberShipProvider.MembershipProvider"
    6                connectionStringName="ConnectionStringTest"
    7                enablePasswordRetrieval="true"
    8                enablePasswordReset="true"
    9                requiresQuestionAndAnswer="false" />
    10         </providers>
    11       </membership>
    
     

    MembershipProvider.vb

    1    Public Overrides Sub Initialize(ByVal name As String, ByVal config As NameValueCollection)
    2            ...    
    3            Dim ConnectionStringSettings As ConnectionStringSettings = ConfigurationManager.ConnectionStrings(config("ConnectionStringTest"))
    4    
    5            If ConnectionStringSettings Is Nothing OrElse ConnectionStringSettings.ConnectionString.Trim() = String.Empty Then
    6                Throw New ProviderException("Connection string cannot be blank.")
    7            End If
    8    
    9            _sqlConnectionString = ConnectionStringSettings.ConnectionString
    10   
    11   End Sub
    
     
    - km

    ______________________________________

    "always here and always forever"
  • Re: Connection String can't be blank..

    05-16-2008, 2:51 PM
    • Loading...
    • kamii47
    • Joined on 05-26-2005, 4:04 PM
    • Karachi, Pakistan
    • Posts 1,520

     Please let us see your full web.config

    Have you put connection string

    <connectionStrings>
            <add name="ConnectionStringTest" connectionString="server=ty\yukon;database=5656;UID=sa;PWD=sa;Pooling=false" providerName="System.Data.SqlClient"/>
        </connectionStrings>

    Kamran Shahid(MCSD.NET,MCPD.net[web])
    Sr. Software Engineer
    Netprosys Inc.
    www.netprosys.com

    Remember to click "Mark as Answer" on the post that helps U
  • Re: Connection String can't be blank..

    05-16-2008, 3:29 PM
    • Loading...
    • griff303
    • Joined on 02-03-2004, 11:53 AM
    • Posts 652

    here is my full Web.config

     

     

    1    <?xml version="1.0"?>
    2    <configuration>
    3    	<configSections>
    4    		<sectionGroup name="system.web.extensions" type="System.Web.Configuration.SystemWebExtensionsSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
    5    			<sectionGroup name="scripting" type="System.Web.Configuration.ScriptingSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
    6    				<section name="scriptResourceHandler" type="System.Web.Configuration.ScriptingScriptResourceHandlerSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/>
    7    				<sectionGroup name="webServices" type="System.Web.Configuration.ScriptingWebServicesSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
    8    					<section name="jsonSerialization" type="System.Web.Configuration.ScriptingJsonSerializationSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="Everywhere"/>
    9    					<section name="profileService" type="System.Web.Configuration.ScriptingProfileServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/>
    10   					<section name="authenticationService" type="System.Web.Configuration.ScriptingAuthenticationServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/>
    11   					<section name="roleService" type="System.Web.Configuration.ScriptingRoleServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/></sectionGroup>
    12   			</sectionGroup>
    13   		</sectionGroup>
    14   	</configSections>
    15   	<connectionStrings>
    16       <!--<add name="ConnectionString" connectionString="Data Source=XXXX.XXXX.com;Initial Catalog=XXXX;User ID=XXXX;Password=XXXX;" providerName="System.Data.SqlClient" />-->
    17       <add name="ConnectionStringTest" connectionString="Data Source=XXXX.XXXX.com;Initial Catalog=XXXX;User ID=XXXX;Password=XXXX" providerName="System.Data.SqlClient" />
    18    </connectionStrings>
    19    <system.web>
    20   		<pages>
    21   			<controls>
    22   				<add tagPrefix="asp" namespace="System.Web.UI" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
    23   				<add namespace="AjaxControlToolkit" assembly="AjaxControlToolkit" tagPrefix="ajaxToolkit"/>
    24   				<add tagPrefix="asp" namespace="System.Web.UI.WebControls" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/></controls>
    25   		</pages>
    26   
    27       <authentication mode="Forms">
    28         <forms defaultUrl="login.aspx" name=".ASPSTPAUTH"></forms>
    29       </authentication>
    30       <authorization>
    31         <deny users="?" />
    32       </authorization>
    33   
    34      <machineKey
    35         validationKey="C50B3C89CB21F4F1422FF158A5B42D0E8DB8CB5CDA1742572A487D9401E3400267682B202B746511891C1BAF47F8D25C07F6C39A104696DB51F17C529AD3CABE"
    36         decryptionKey="8A9BE8FD67AF6979E7D20198CFEA50DD3D3799C77AF2B72F"
    37         validation="SHA1" />
    38      
    39       <!-- Customer Membership Provider Begin -->
    40       <membership defaultProvider="MembershipProvider">
    41         <providers>
    42           <clear />
    43           <add name="MemberShipProvider" 
    44               type="MemberShipProvider.MembershipProvider"
    45               connectionStringName="ConnectionStringTest"
    46               enablePasswordRetrieval="true"
    47               enablePasswordReset="true"
    48               requiresQuestionAndAnswer="false" />
    49         </providers>
    50       </membership>
    51       <!-- Customer Membership Provider End -->
    52      
    53   		<!--
    54             Set compilation debug="true" to insert debugging
    55             symbols into the compiled page. Because this
    56             affects performance, set this value to true only
    57             during development.
    58       -->
    59      <customErrors mode="Off" />
    60      
    61   		<compilation debug="true">
    62   			<assemblies>
    63   				<add assembly="System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
    64   				<add assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
    65   				<add assembly="System.Xml.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
    66   				<add assembly="System.Data.DataSetExtensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
    67   				<add assembly="System.Data.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/></assemblies></compilation>
    68   		<httpHandlers>
    69   			<remove verb="*" path="*.asmx"/>
    70   			<add verb="*" path="*.asmx" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
    71   			<add verb="*" path="*_AppService.axd" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
    72   			<add verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" validate="false"/>
    73   		</httpHandlers>
    74   		<httpModules>
    75   			<add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
    76   		</httpModules>
    77   	</system.web>
    78    <system.webServer>
    79   		<validation validateIntegratedModeConfiguration="false"/>
    80   		<modules>
    81   			<remove name="ScriptModule"/><add name="ScriptModule" preCondition="managedHandler" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
    82   		</modules>
    83   		<handlers>
    84   			<remove name="ScriptHandlerFactory"/>
    85   			<remove name="ScriptHandlerFactoryAppServices"/>
    86   			<remove name="ScriptResource"/><remove name="WebServiceHandlerFactory-Integrated"/>
    87   			<add name="ScriptHandlerFactory" verb="*" path="*.asmx" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
    88   			<add name="ScriptHandlerFactoryAppServices" verb="*" path="*_AppService.axd" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
    89   			<add name="ScriptResource" preCondition="integratedMode" verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
    90   		</handlers>
    91   	</system.webServer>
    92   	<system.codedom>
    93   		<compilers>
    94   			<compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CSharp.CSharpCodeProvider,System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" warningLevel="4">
    95   				<providerOption name="CompilerVersion" value="v3.5"/>
    96   				<providerOption name="WarnAsError" value="false"/></compiler>
    97   			<compiler language="vb;vbs;visualbasic;vbscript" extension=".vb" type="Microsoft.VisualBasic.VBCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" warningLevel="4">
    98   				<providerOption name="CompilerVersion" value="v3.5"/>
    99   				<providerOption name="OptionInfer" value="true"/>
    100  				<providerOption name="WarnAsError" value="false"/></compiler></compilers></system.codedom>
    101  	<runtime>
    102  		<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
    103  			<dependentAssembly>
    104  				<assemblyIdentity name="System.Web.Extensions" publicKeyToken="31bf3856ad364e35"/>
    105  				<bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="3.5.0.0"/></dependentAssembly>
    106  			<dependentAssembly>
    107  				<assemblyIdentity name="System.Web.Extensions.Design" publicKeyToken="31bf3856ad364e35"/>
    108  				<bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="3.5.0.0"/></dependentAssembly></assemblyBinding></runtime></configuration>
    109  
    
     
    - km

    ______________________________________

    "always here and always forever"
  • Re: Connection String can't be blank..

    05-16-2008, 3:45 PM
    • Loading...
    • kamii47
    • Joined on 05-26-2005, 4:04 PM
    • Karachi, Pakistan
    • Posts 1,520

    Change

    Dim ConnectionStringSettings As ConnectionStringSettings = ConfigurationManager.ConnectionStrings(config("ConnectionStringTest"))
    to
    Dim ConnectionStringSettings As ConnectionStringSettings = ConfigurationManager.ConnectionStrings("ConnectionStringTest") 
     
    Kamran Shahid(MCSD.NET,MCPD.net[web])
    Sr. Software Engineer
    Netprosys Inc.
    www.netprosys.com

    Remember to click "Mark as Answer" on the post that helps U
  • Re: Connection String can't be blank..

    05-16-2008, 4:19 PM
    Answer
    • Loading...
    • griff303
    • Joined on 02-03-2004, 11:53 AM
    • Posts 652

    After a few minutes looking at it I noticed for some reason I had changed the static text in the line below to the actual name of the Connection string.

    What I had 

    Dim ConnectionStringSettings As ConnectionStringSettings = ConfigurationManager.ConnectionStrings(config("ConnectionStringTest"))

    Should be and changed to

    Dim ConnectionStringSettings As ConnectionStringSettings = ConfigurationManager.ConnectionStrings(config("connectionStringName")) - this references the connectionStringName in the provider

    1   <membership defaultProvider="MembershipProvider">
    2          <providers>
    3            <clear />
    4            <add name="StaplesMemberShipProvider"
    5                type="MemberShipProvider.MembershipProvider"
    6                connectionStringName="ConnectionStringTest"
    7                enablePasswordRetrieval="true"
    8                enablePasswordReset="true"
    9                requiresQuestionAndAnswer="false" />
    10         </providers>
    11       </membership>

     

     

    - km

    ______________________________________

    "always here and always forever"
Page 1 of 1 (5 items)