473,412 Members | 5,714 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,412 software developers and data experts.

Weird problem with connection strings

Hi All

I have a really strange problem occurring in my application. When I read in
the application settings for connection strings the following happens:

Here are my connection string settings -
<connectionStrings>

<add name="TRM8.UI.My.MySettings.TRM8" connectionString="Data
Source=SQLDATA;Initial Catalog=TRM8_PROD;Integrated Security=True"

providerName="System.Data.SqlClient" />

<add name="TRM8.UI.My.MySettings.TRM8_Test" connectionString="Data
Source=SQLDATA;Initial Catalog=TRM8_UAT;Integrated Security=True"

providerName="System.Data.SqlClient" />

</connectionStrings>

Now when i read in these settings -

Private Sub New()
_colConnectStrings =
System.Configuration.ConfigurationManager.Connecti onStrings

'this is for test purposes

Dim conEnum As IEnumerator = _colConnectStrings.GetEnumerator()

Dim i As Integer = 0

While conEnum.MoveNext()

Dim name As String = _colConnectStrings(i).Name

Dim connectionString As String = _

_colConnectStrings(name).ConnectionString

Dim provider As String = _

_colConnectStrings(name).ProviderName

End While

'the above returns 3 (THREE) instances (all the same) of the following:

'name = "LocalSqlServer"

'connection string = "data source=.\SQLEXPRESS;Integrated
Security=SSPI;AttachDBFilename=|DataDirectory|aspn etdb.mdf;User
Instance=true"

'provider = "System.Data.SqlClient"

End Sub

The consequence of the above is that I cannot get a connection to my
database (Sql Server 2005) as the _colConnectStrings collection does not
contain my real connection strings.

I do NOT have any setting like it in the app config file, neither do I have
SQLExpress installed on my development machine. I have tried removing my
connection strings from application settings, closing VS and resetting the
connection strings. The project is quite large with some 90k lines of code.
VB.Net 2005 running on WinXP SP2.

This one has me beat. I am unable to find any help on this anywhere.

Thank you in advance for any help you can provide.
Jun 14 '07 #1
3 1977
Harry Strybos wrote:
I have a really strange problem occurring in my application. When I
read in the application settings for connection strings the following
happens:
Here are my connection string settings -
<connectionStrings>

<add name="TRM8.UI.My.MySettings.TRM8" connectionString="Data
Source=SQLDATA;Initial Catalog=TRM8_PROD;Integrated Security=True"
providerName="System.Data.SqlClient" />
<add name="TRM8.UI.My.MySettings.TRM8_Test" connectionString="Data
Source=SQLDATA;Initial Catalog=TRM8_UAT;Integrated Security=True"
providerName="System.Data.SqlClient" />
</connectionStrings>

Now when i read in these settings -
<snip code>
'the above returns 3 (THREE) instances (all the same) of the
following:
'name = "LocalSqlServer"
'connection string = "data source=.\SQLEXPRESS;Integrated
Security=SSPI;AttachDBFilename=|DataDirectory|aspn etdb.mdf;User
Instance=true"
'provider = "System.Data.SqlClient"

The consequence of the above is that I cannot get a connection to my
database (Sql Server 2005) as the _colConnectStrings collection does
not contain my real connection strings.
It *really* looks like it's reading from a different file than the one you
intend. Can you get your computer to search in all files for the data that's
being retrieved? (I'd trust something like Agent Ransack more than Windows'
search for doing that.)

Andrew
Jun 15 '07 #2
You don't update the "i" variable so it returns always the same connection
string (the first one that is AFAIK defined in machine.config).

---
Patrice
"Harry Strybos" <ha**********@ffapaysmart.com.aua écrit dans le message de
news: %2****************@TK2MSFTNGP02.phx.gbl...
Hi All

I have a really strange problem occurring in my application. When I read
in the application settings for connection strings the following happens:

Here are my connection string settings -
<connectionStrings>

<add name="TRM8.UI.My.MySettings.TRM8" connectionString="Data
Source=SQLDATA;Initial Catalog=TRM8_PROD;Integrated Security=True"

providerName="System.Data.SqlClient" />

<add name="TRM8.UI.My.MySettings.TRM8_Test" connectionString="Data
Source=SQLDATA;Initial Catalog=TRM8_UAT;Integrated Security=True"

providerName="System.Data.SqlClient" />

</connectionStrings>

Now when i read in these settings -

Private Sub New()
_colConnectStrings =
System.Configuration.ConfigurationManager.Connecti onStrings

'this is for test purposes

Dim conEnum As IEnumerator = _colConnectStrings.GetEnumerator()

Dim i As Integer = 0

While conEnum.MoveNext()

Dim name As String = _colConnectStrings(i).Name

Dim connectionString As String = _

_colConnectStrings(name).ConnectionString

Dim provider As String = _

_colConnectStrings(name).ProviderName

End While

'the above returns 3 (THREE) instances (all the same) of the following:

'name = "LocalSqlServer"

'connection string = "data source=.\SQLEXPRESS;Integrated
Security=SSPI;AttachDBFilename=|DataDirectory|aspn etdb.mdf;User
Instance=true"

'provider = "System.Data.SqlClient"

End Sub

The consequence of the above is that I cannot get a connection to my
database (Sql Server 2005) as the _colConnectStrings collection does not
contain my real connection strings.

I do NOT have any setting like it in the app config file, neither do I
have SQLExpress installed on my development machine. I have tried removing
my connection strings from application settings, closing VS and resetting
the connection strings. The project is quite large with some 90k lines of
code. VB.Net 2005 running on WinXP SP2.

This one has me beat. I am unable to find any help on this anywhere.

Thank you in advance for any help you can provide.


Jun 15 '07 #3

"Patrice" <http://www.chez.com/scribe/wrote in message
news:uu**************@TK2MSFTNGP04.phx.gbl...
You don't update the "i" variable so it returns always the same connection
string (the first one that is AFAIK defined in machine.config).

---
Patrice
Thank you for your help. How stupid of me....I did not see the problem with
the i variable.

This whole thing came about because I was getting an null error from the
following:
Return _colConnectStrings.Item(DatabaseName).ToString

gives me this error

"System.NullReferenceException occurred
Message="Object reference not set to an instance of an object."
Source="DAL"
StackTrace:
at DAL.FFAConnStrings.GetConnectStringByRole(String DatabaseName) in
C:\AAProjects.Net\FFAPaySmart.DAL\FFAConnStrings.v b:line 62"

even though _colConnectStrings has a count of 3 and has Databasename as one
of its items. Still a strange problem
>
"Harry Strybos" <ha**********@ffapaysmart.com.aua écrit dans le message
de news: %2****************@TK2MSFTNGP02.phx.gbl...
>Hi All

I have a really strange problem occurring in my application. When I read
in the application settings for connection strings the following happens:

Here are my connection string settings -
<connectionStrings>

<add name="TRM8.UI.My.MySettings.TRM8" connectionString="Data
Source=SQLDATA;Initial Catalog=TRM8_PROD;Integrated Security=True"

providerName="System.Data.SqlClient" />

<add name="TRM8.UI.My.MySettings.TRM8_Test" connectionString="Data
Source=SQLDATA;Initial Catalog=TRM8_UAT;Integrated Security=True"

providerName="System.Data.SqlClient" />

</connectionStrings>

Now when i read in these settings -

Private Sub New()
_colConnectStrings =
System.Configuration.ConfigurationManager.Connect ionStrings

'this is for test purposes

Dim conEnum As IEnumerator = _colConnectStrings.GetEnumerator()

Dim i As Integer = 0

While conEnum.MoveNext()

Dim name As String = _colConnectStrings(i).Name

Dim connectionString As String = _

_colConnectStrings(name).ConnectionString

Dim provider As String = _

_colConnectStrings(name).ProviderName

End While

'the above returns 3 (THREE) instances (all the same) of the following:

'name = "LocalSqlServer"

'connection string = "data source=.\SQLEXPRESS;Integrated
Security=SSPI;AttachDBFilename=|DataDirectory|asp netdb.mdf;User
Instance=true"

'provider = "System.Data.SqlClient"

End Sub

The consequence of the above is that I cannot get a connection to my
database (Sql Server 2005) as the _colConnectStrings collection does not
contain my real connection strings.

I do NOT have any setting like it in the app config file, neither do I
have SQLExpress installed on my development machine. I have tried
removing my connection strings from application settings, closing VS and
resetting the connection strings. The project is quite large with some
90k lines of code. VB.Net 2005 running on WinXP SP2.

This one has me beat. I am unable to find any help on this anywhere.

Thank you in advance for any help you can provide.



Jun 17 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Kaneda | last post by:
Hello everyone! I have some weird(?) problems, and I am not quite sure if there are due to my errors or maybe a limitation in the .Net framework. I have a ComboBox I need to fill with the...
0
by: Kaneda | last post by:
Hello everyone! I have some weird(?) problems, and I am not quite sure if there are due to my errors or maybe a limitation in the .Net framework. I have a ComboBox I need to fill with the...
10
by: Bonj | last post by:
Hello. I hope somebody can help me on this, because I'm running out of options to turn to. I have almost solved my regular expression function. Basically it works OK if unicode is defined. It...
1
by: Gerard Marshall Vignes | last post by:
I was recently cautioned against storing an ADO.NET Connection String in the Windows Registry because access to the Windows Registry would be serialized and therefore impact scalability. I have...
3
by: Sean Shanny | last post by:
To all, We are running postgresql 7.4.1 on an G5 with dual procs, OSX 10.3.3 server, 8GB mem, attached to a fully configured 3.5TB XRaid box via fibre channel. I think we have run into this...
14
by: WStoreyII | last post by:
the following code is supposed to read a whole line upto a new line char from a file. however it does not work. it is producing weird results. please help. I had error checking in there for...
2
by: Mike P | last post by:
I've always put my connection strings in the web.config, but I've just recently seen an example of a connection string in a resource file. What are the advantages of doing this, and could you do it...
9
by: =?Utf-8?B?Vmlua2k=?= | last post by:
Hello Everyone, I have a question about storing the connection strings to the database in a config file or database. My manager wants me to store all the connection strings in a database, but I...
3
by: sophie_newbie | last post by:
Hi, I want to store python text strings that characters like "é" "Č" in a mysql varchar text field. Now my problem is that mysql does not seem to accept these characters. I'm wondering if there...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.