PC Review


Reply
Thread Tools Rate Thread

How To :App.Config

 
 
Sincere
Guest
Posts: n/a
 
      8th Jul 2009
Hello,

I am having probelms reading the app.config file. I have stored my
connectionstring as follows.

<add name ="ReqCon" connectionString =
"Data Source= {local};Initial Catalog=Tasks_Sch;
Integrated Security=SSPI" providerName ="System.Data.SqlClient"/>
</connectionStrings>


Following is the code in the data layer class:

Imports System
Imports Microsoft.ApplicationBlocks.Data
Imports System.Data
Imports System.Data.SqlClient
Imports System.Configuration.ConfigurationManager
Imports System.Configuration


Dim strConnect As String =
System.Configuration.ConfigurationManager.AppSettings("ReqCon")
cn.ConnectionString = (strConnect)
cn.Open()

Database server am using is SQL 2005


TIA

Regards
 
Reply With Quote
 
 
 
 
Cor Ligthert[MVP]
Guest
Posts: n/a
 
      8th Jul 2009
Because the Net method gives often for some people problems, there is in VB
the much easier namespace My which contains the shared class

My.Settings

Have a look at that

Cor

"Sincere" <(E-Mail Removed)> wrote in message
news:0DF096F7-37F1-4A08-A62B-(E-Mail Removed)...
> Hello,
>
> I am having probelms reading the app.config file. I have stored my
> connectionstring as follows.
>
> <add name ="ReqCon" connectionString =
> "Data Source= {local};Initial Catalog=Tasks_Sch;
> Integrated Security=SSPI" providerName ="System.Data.SqlClient"/>
> </connectionStrings>
>
>
> Following is the code in the data layer class:
>
> Imports System
> Imports Microsoft.ApplicationBlocks.Data
> Imports System.Data
> Imports System.Data.SqlClient
> Imports System.Configuration.ConfigurationManager
> Imports System.Configuration
>
>
> Dim strConnect As String =
> System.Configuration.ConfigurationManager.AppSettings("ReqCon")
> cn.ConnectionString = (strConnect)
> cn.Open()
>
> Database server am using is SQL 2005
>
>
> TIA
>
> Regards


 
Reply With Quote
 
Family Tree Mike
Guest
Posts: n/a
 
      8th Jul 2009


"Sincere" wrote:

> Hello,
>
> I am having probelms reading the app.config file. I have stored my
> connectionstring as follows.
>
> <add name ="ReqCon" connectionString =
> "Data Source= {local};Initial Catalog=Tasks_Sch;
> Integrated Security=SSPI" providerName ="System.Data.SqlClient"/>
> </connectionStrings>
>
>
> Following is the code in the data layer class:
>
> Imports System
> Imports Microsoft.ApplicationBlocks.Data
> Imports System.Data
> Imports System.Data.SqlClient
> Imports System.Configuration.ConfigurationManager
> Imports System.Configuration
>
>
> Dim strConnect As String =
> System.Configuration.ConfigurationManager.AppSettings("ReqCon")
> cn.ConnectionString = (strConnect)
> cn.Open()
>
> Database server am using is SQL 2005
>
>
> TIA
>
> Regards


Shouldn't you be using ConfigurationManager.ConnectionStrings, rather than
ConfigurationManager.AppSettings?

Mike
 
Reply With Quote
 
Sincere
Guest
Posts: n/a
 
      8th Jul 2009
so the namespace name is My.Settings ?

"Cor Ligthert[MVP]" wrote:

> Because the Net method gives often for some people problems, there is in VB
> the much easier namespace My which contains the shared class
>
> My.Settings
>
> Have a look at that
>
> Cor
>
> "Sincere" <(E-Mail Removed)> wrote in message
> news:0DF096F7-37F1-4A08-A62B-(E-Mail Removed)...
> > Hello,
> >
> > I am having probelms reading the app.config file. I have stored my
> > connectionstring as follows.
> >
> > <add name ="ReqCon" connectionString =
> > "Data Source= {local};Initial Catalog=Tasks_Sch;
> > Integrated Security=SSPI" providerName ="System.Data.SqlClient"/>
> > </connectionStrings>
> >
> >
> > Following is the code in the data layer class:
> >
> > Imports System
> > Imports Microsoft.ApplicationBlocks.Data
> > Imports System.Data
> > Imports System.Data.SqlClient
> > Imports System.Configuration.ConfigurationManager
> > Imports System.Configuration
> >
> >
> > Dim strConnect As String =
> > System.Configuration.ConfigurationManager.AppSettings("ReqCon")
> > cn.ConnectionString = (strConnect)
> > cn.Open()
> >
> > Database server am using is SQL 2005
> >
> >
> > TIA
> >
> > Regards

>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
dll config and web.config and Label Expressions (binding label text to dll config settings) CSharpner Microsoft ASP .NET 0 9th Apr 2007 11:00 PM
DTDs for machine.config, web.config, security.config available ? =?Utf-8?B?UGF1bCBLZW5uZWR5?= Microsoft Dot NET Framework 1 5th Feb 2007 06:42 AM
sharedListeners config in app.config file doesn't recognize customlocation attribute RJ Microsoft Dot NET 0 1st Nov 2006 09:48 PM
using ReadXml to read exe.config file into Grid and update the exe.config using WriteXml hazz Microsoft C# .NET 0 7th Jul 2006 11:32 PM
Configuration Error - c:\winnt\microsoft.net\framework\v1.1.4322\Config\machine.config Ivan Microsoft ASP .NET 1 21st May 2004 06:18 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:42 PM.