Type 'ConnectionStringData' is not defined.

D

dmbuso

I'm migrating a VB.NET 2003 application to VB.NET 2008. The 2003 app used the
June 2005 Enterprise Library while I'm going to use the latest EntLib, 4.0 -
May 2008.

I copied the 2003 app to a new 2008 folder structure, recreated the
app.config using the new 4.0 EntLib config tool, and referenced the 4.0
Microsoft.Practices.EnterpriseLibrary.Data.dll file.

The problem is there is a Function that has errors in it and I'm not sure
how to fix these.

Here are the lines of code and their respective errors:

Dim authConnectString As ConnectionStringData
Error: Type 'ConnectionStringData' is not defined.

authConnectString =
dbSettings.ConnectionStrings.Item(String.Concat(Common.Constants.AuthDbInstanceName, "_CS"))
Error: 'ConnectionStrings' is not a member of
'Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings'.

authInstance = New InstanceData(Common.Constants.AuthDbInstanceName)
Error: Argument not specified for parameter 'sample' of 'Public Sub
New(instanceName As String, sample As System.Diagnostics.CounterSample)'.

There are a few more. Please contact me and I'll send you the Function so
you can take a look at it.
 
D

dmbuso

Cor,

Thanks for the article. I read it, but I don't think this is really the
route I should go. I viewed the app.config with XML Notepad and I think what
I need to do is to read the 'connectionStrings' node contained in the
app.config.

Here's what it looks like in XML Notepad:

<connectionStrings>
<add name="LocalAuth_CS" connectionString="Server=.;Integrated
Security=True" providerName="System.Data.SqlClient"/>
<add name="RAID_CS" connectionString="Database=RAID;Server=.;Integrated
Security=False;User ID=RaidApp;Password="";Connect Timeout=30"
providerName="System.Data.SqlClient"/>
<add name="RAIDAuth_CS" connectionString="Database=RAID;Server=.;Integrated
Security=True" providerName="System.Data.SqlClient"/>
</connectionStrings>

Also and as a side note, I created the app.config with the EntLib 4.0 config
tool.

This function is giving me an error also. It is telling me that that
GetConfiguration is not a member of Sytem.Configuration.ConfigurationManager.
I think this is where I need to read the connection strings.

Private Shared Function ReadDBSettings() As DatabaseSettings
Return
CType(ConfigurationManager.GetConfiguration("dataConfiguration"),
DatabaseSettings)
End Function


Here is my email: (e-mail address removed)
and Work Phone: (814) 532-4925
--
Dave B.


Cor Ligthert said:
dmbuso-

Have a look at this one, which is a special VB method

http://msdn.microsoft.com/en-us/library/ms379611(VS.80).aspx

-Cor
 
S

Steven Cheng [MSFT]

Hi Dave,

Since the project is converted from VS 2003 to VS 2008 and it has changed
much from .NET framework 1.1 to 2.0(or 3.5), especially for the
configuration management architecture, it is possible that many such
configuration related code will get broken.

As for the code snippet you provided:

===================
 
S

Steven Cheng [MSFT]

Thanks for your reply Dave,

Yes, .NET 2.0 and .NET 3.5 doesn't have much difference, however, since
your original code is coupled with .NET framework 1.1, the framework and
enterprise library for that framework has changed much. Therefore, I
suggeset you check any of those classes which is no longer used in the new
framework or new enterprise library and replace them with the new syntax or
code style. Have you tried changing the database accessing code as I
mentioned in previous message to see whether the error disappears?

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
From: =?Utf-8?B?ZG1idXNv?= <[email protected]>
References: <[email protected]>
Subject: RE: Type 'ConnectionStringData' is not defined.
Date: Tue, 1 Jul 2008 05:09:03 -0700
 
D

dmbuso

Steven,

No I haven't tried your supposed code change because your response is the
same as what I had. Could you please repost it?

Here is the line of code and the error it yields:

authConnectString =
dbSettings.ConnectionStrings.Item(String.Concat(Common.Constants.AuthDbInstanceName, "_CS"))

Error: 'ConnectionStrings' is not a member of
'Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings'.
 
S

Steven Cheng [MSFT]

Thanks for your reply Dave,

Oh, my omit. I just found that my first reply got truncated due to some
tool issue. I'll compose a new one and post here soon. Really sorry for the
misleading and inconvenience.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
From: =?Utf-8?B?ZG1idXNv?= <[email protected]>
References: <[email protected]>
<[email protected]>
Subject: RE: Type 'ConnectionStringData' is not defined.
Date: Wed, 2 Jul 2008 05:06:01 -0700
Steven,

No I haven't tried your supposed code change because your response is the
same as what I had. Could you please repost it?

Here is the line of code and the error it yields:

authConnectString =
dbSettings.ConnectionStrings.Item(String.Concat(Common.Constants.AuthDbInsta
nceName, "_CS"))
 
S

Steven Cheng [MSFT]

Hi Dave,

In my first reply, I mentioned some suggestion about the two problems you
said in your initial messsage.

1. About the ConnectionStringData. It is apparently that, from .net
framework 2.0, this class type will not be used (also for the new
enterprise library). And since .net framework 2.0 application's app.config
file has built-in connection string support, the entlib will also utlize
it. The typical code that establish database connection and perform command
operation is like below:

=========================


Public Function UpdateProducts() As Integer
' Create the Database object, using the default database service.
The
' default database service is determined through configuration.
Dim db As Database = DatabaseFactory.CreateDatabase()

Dim productsDataSet As DataSet = New DataSet

Dim sqlCommand As String = "Select ProductID, ProductName,
CategoryID, UnitPrice, LastUpdate " & _
"From Products"
Dim dbCommand As DbCommand = db.GetSqlStringCommand(sqlCommand)

.........................

=========================

it use a DatabaseFactory to direclty get a DataBase object(the default one
or you can supply a name).

And for the ConfigurationManager class, it doesn't have a
"GetConfiguration" method, only a "GetSection" method is available. You can
refer to the available member list of ConfigurationManager class:

#ConfigurationManager Members
http://msdn.microsoft.com/en-us/library/system.configuration.configurationma
nager_members.aspx

Also, I think you can refer to some of the samples in the enterprise
library 4.0(such as the data access ones) and convert those old style
code(in entlib 1.1) to the new style ones.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
Subject: RE: Type 'ConnectionStringData' is not defined.
Date: Wed, 2 Jul 2008 05:06:01 -0700
Steven,

No I haven't tried your supposed code change because your response is the
same as what I had. Could you please repost it?

Here is the line of code and the error it yields:

authConnectString =
dbSettings.ConnectionStrings.Item(String.Concat(Common.Constants.AuthDbInsta
nceName, "_CS"))
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top