locked
About connectionstring RRS feed

  • Question

  • User-788967271 posted

    Hi all:

    I have in web.config

    <connectionStrings>
    		<add name="Cresolia" connectionString="Data Source=USUARIO-HP\CRESOLIA;Initial Catalog=Cresolia;Integrated Security=sspi"/>
    		<add name="Cresoliaza" connectionString="Data Source=USUARIO-HP\CRESOLIA;Initial Catalog=Cresoliaza;Integrated Security=sspi"/>
    		<add name="Cresolina" connectionString="Data Source=USUARIO-HP\CRESOLIA;Initial Catalog=Cresolina;Integrated Security=sspi"/>
    		<add name="Cresolined" connectionString="Data Source=USUARIO-HP\CRESOLIA;Initial Catalog=Cresolined;Integrated Security=sspi"/>
    		<add name="Cresolis" connectionString="Data Source=USUARIO-HP\CRESOLIA;Initial Catalog=Cresolis;Integrated Security=sspi"/>
    		<add name="Cuentas" connectionString="Data Source=USUARIO-HP\CRESOLIA;Initial Catalog=Cuentas;Integrated Security=sspi"/>
    		<add name="Historico Cresolia" connectionString="Data Source=USUARIO-HP\CRESOLIA;Initial Catalog=Historico Cresolia;Integrated Security=sspi"/>
    		<add name="Historico Cresoliaza" connectionString="Data Source=USUARIO-HP\CRESOLIA;Initial Catalog=Historico Cresoliaza;Integrated Security=sspi"/>
    		<add name="Historico Cresolina" connectionString="Data Source=USUARIO-HP\CRESOLIA;Initial Catalog=Historico Cresolina;Integrated Security=sspi"/>
    		<add name="Historico Cresolined" connectionString="Data Source=USUARIO-HP\CRESOLIA;Initial Catalog=Historico Cresolined;Integrated Security=sspi"/>
    		<add name="Historico Cresolis" connectionString="Data Source=USUARIO-HP\CRESOLIA;Initial Catalog=Historico Cresolis;Integrated Security=sspi"/>
    	</connectionStrings>

    In codebehind I have

            Dim strconexion As String
            If Request.QueryString("historico") IsNot Nothing Then
                strconexion = "Historico Cresolia"
            Else
                strconexion = "Cresolia"
            End If
            Dim cnconexion As New SqlConnection(ConfigurationManager.ConnectionStrings(strconexion).ConnectionString)
    

    When strconexion is "Cresolia" it is ok. But when it is "Historico Cresolia" it fails and I receive an  System.ArgumentException.

    El formato de la cadena de inicialización no se ajusta a la especificación que comienza en el índice 0.

    This error tells me something is wrong with the coneectionstring. What is wrong?

    Thanks in advance



     

     

    Saturday, June 8, 2013 4:21 AM

Answers

  • User1992938117 posted

    Hi again:

    No luck, it is not a mater of white spaces

    I tried "Historico_Cresolia" and "Historico"

     i tested from my end both cases are working.

    One more thing you have your database name with spaces, that is also not allowed, could you try after removing that !

    Initial Catalog=HistoricoCresolia

    Try as above
     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, June 8, 2013 2:14 PM

All replies

  • User1992938117 posted

    <add name="Historico Cresolia" connectionString="Data Source=USUARIO-HP\CRESOLIA;Initial Catalog=Historico Cresolia;Integrated Security=sspi"/>
    		<add name="Historico Cresoliaza" connectionString="Data Source=USUARIO-HP\CRESOLIA;Initial Catalog=Historico Cresoliaza;Integrated Security=sspi"/>
    		<add name="Historico Cresolina" connectionString="Data Source=USUARIO-HP\CRESOLIA;Initial Catalog=Historico Cresolina;Integrated Security=sspi"/>
    		<add name="Historico Cresolined" connectionString="Data Source=USUARIO-HP\CRESOLIA;Initial Catalog=Historico Cresolined;Integrated Security=sspi"/>
    		<add name="Historico Cresolis" connectionString="Data Source=USUARIO-HP\CRESOLIA;Initial Catalog=Historico Cresolis;Integrated Security=sspi"/>
    

    Ideally speaking you should not have white spaces in config name or key values, Relplace White spaces with _ and then compare

    <add name="Historico_Cresolia" connectionString="Data Source=USUARIO-HP\CRESOLIA;Initial Catalog=Historico Cresolia;Integrated Security=sspi"/>
    		<add name="Historico_Cresoliaza" connectionString="Data Source=USUARIO-HP\CRESOLIA;Initial Catalog=Historico Cresoliaza;Integrated Security=sspi"/>
    		<add name="Historico_Cresolina" connectionString="Data Source=USUARIO-HP\CRESOLIA;Initial Catalog=Historico Cresolina;Integrated Security=sspi"/>
    		<add name="Historico_Cresolined" connectionString="Data Source=USUARIO-HP\CRESOLIA;Initial Catalog=Historico Cresolined;Integrated Security=sspi"/>
    		<add name="Historico_Cresolis" connectionString="Data Source=USUARIO-HP\CRESOLIA;Initial Catalog=Historico Cresolis;Integrated Security=sspi"/>
     Dim a As String = "historico"
            Dim strconexion As String
            If a IsNot Nothing Then
                strconexion = "Historico_Cresolia"
            Else
                strconexion = "Cresolia"
            End If
            Dim cnconexion As New SqlConnection(ConfigurationManager.ConnectionStrings(strconexion).ConnectionString)



     

    Saturday, June 8, 2013 5:00 AM
  • User-848409960 posted

    I am not sure...

    Maybe you can't have spaces in a connection string names.

    Try removeing them

    Saturday, June 8, 2013 5:39 AM
  • User-1716253493 posted
    Try name= "Historico&nbsp;Cresolia"
    Saturday, June 8, 2013 5:52 AM
  • User-788967271 posted

    Hi again:

    No luck, it is not a mater of white spaces

    I tried "Historico_Cresolia" and "Historico"

    What can be wrong?

    Thanks for all the replies

    Saturday, June 8, 2013 6:58 AM
  • User-1716253493 posted
    strconexion = "Historico_Cresolia" change also this line
    Saturday, June 8, 2013 7:33 AM
  • User1992938117 posted

    Hi again:

    No luck, it is not a mater of white spaces

    I tried "Historico_Cresolia" and "Historico"

     i tested from my end both cases are working.

    One more thing you have your database name with spaces, that is also not allowed, could you try after removing that !

    Initial Catalog=HistoricoCresolia

    Try as above
     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, June 8, 2013 2:14 PM