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?
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)
Member
72 Points
292 Posts
About connectionstring
Jun 08, 2013 04:21 AM|Volar|LINK
Hi all:
I have in web.config
In codebehind I have
When strconexion is "Cresolia" it is ok. But when it is "Historico Cresolia" it fails and I receive an System.ArgumentException.
This error tells me something is wrong with the coneectionstring. What is wrong?
Thanks in advance
Star
14742 Points
3114 Posts
Re: About connectionstring
Jun 08, 2013 04:57 AM|adeelehsan|LINK
Have a look at the following:
http://stackoverflow.com/questions/11235416/format-of-the-initialization-string-does-not-conform-to-specification-starting-a
MCSD[ASP.NET 4.5, SharePoint 2013], MCTS [WSS 3.0, MOSS 2007, SharePoint 2010], MCT
Microsoft Community Contributor Award 2011
All-Star
28988 Points
7251 Posts
Re: About connectionstring
Jun 08, 2013 05:00 AM|Rajneesh Verma|LINK
Ideally speaking you should not have white spaces in config name or key values, Relplace White spaces with _ and then compare
www.rajneeshverma.com
Participant
1397 Points
691 Posts
Re: About connectionstring
Jun 08, 2013 05:39 AM|dev.paudel|LINK
I am not sure...
Maybe you can't have spaces in a connection string names.
Try removeing them
Certified MCSD in Web Apps
Chandigarh, India
All-Star
52523 Points
15672 Posts
Re: About connectionstring
Jun 08, 2013 05:52 AM|oned_gk|LINK
Suwandi - Non Graduate Programmer
Member
72 Points
292 Posts
Re: About connectionstring
Jun 08, 2013 06:58 AM|Volar|LINK
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
All-Star
52523 Points
15672 Posts
Re: About connectionstring
Jun 08, 2013 07:33 AM|oned_gk|LINK
Suwandi - Non Graduate Programmer
All-Star
28988 Points
7251 Posts
Re: About connectionstring
Jun 08, 2013 02:14 PM|Rajneesh Verma|LINK
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 !
Try as above
www.rajneeshverma.com