How To :App.Config

  • Thread starter Thread starter Sincere
  • Start date Start date
S

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
 
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 said:
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
 
so the namespace name is My.Settings ?

Cor Ligthert said:
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
 

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

Back
Top