Home All Groups Group Topic Archive Search About
Author
8 Jul 2009 2:52 AM
Sincere
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

Author
8 Jul 2009 8:23 AM
Cor Ligthert[MVP]
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

Show quoteHide quote
"Sincere" <Sinc***@discussions.microsoft.com> wrote in message
news:0DF096F7-37F1-4A08-A62B-9795A7F27366@microsoft.com...
> 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
Author
8 Jul 2009 6:40 PM
Sincere
so the namespace name is My.Settings ?

Show quoteHide quote
"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" <Sinc***@discussions.microsoft.com> wrote in message
> news:0DF096F7-37F1-4A08-A62B-9795A7F27366@microsoft.com...
> > 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
>
>
Author
8 Jul 2009 11:33 AM
Family Tree Mike
Show quote Hide quote
"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