App.Config & Connection Manager

App.Config & Connection Manager

Old forum URL: forums.lhotka.net/forums/t/8310.aspx


st3fanus posted on Thursday, January 07, 2010

Hello I'm Stefanus..

I have a problem with my Connection to Database

I have wrote this connection string in my app.config file , as below :
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <appSettings>
    <add key="Resto_DB"
         value="server=localhost;database=Resto_DB;uid=sa;pwd=abcdef;"/>
  </appSettings>
</configuration>

And I tried to get my constring from application as below :

            using (var ctx = ConnectionManager<SqlConnection>.GetManager("Resto_DB"))
            {
                using (IdentityDal dal = new IdentityDal(ctx))
                {
                    roles = dal.Login(criteria.Username, criteria.Password);
                }
            }

BUT I GOT AN ERROR THAT SAID :
DataPortal.Fetch failed (Database name not found in config file (Resto_DB))

I hope anyone can help me about my problem
Thanks a lot before about respond of my post...

Stefanus


sergeyb replied on Thursday, January 07, 2010

The value should be in ConnectionStrings area, not AppSerttings.

 

Sergey Barskiy

Principal Consultant

office: 678.405.0687 | mobile: 404.388.1899

cid:_2_0648EA840648E85C001BBCB886257279
Microsoft Worldwide Partner of the Year | Custom Development Solutions, Technical Innovation

 

From: st3fanus [mailto:cslanet@lhotka.net]
Sent: Thursday, January 07, 2010 10:12 PM
To: Sergey Barskiy
Subject: [CSLA .NET] App.Config & Connection Manager

 

Hello I'm Stefanus..

I have a problem with my Connection to Database

I have wrote this connection string in my app.config file , as below :
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <appSettings>
    <add key="Resto_DB"
         value="server=localhost;database=Resto_DB;uid=sa;pwd=abcdef;"/>
  </appSettings>
</configuration>

And I tried to get my constring from application as below :

            using (var ctx = ConnectionManager<SqlConnection>.GetManager("Resto_DB"))
            {
                using (IdentityDal dal = new IdentityDal(ctx))
                {
                    roles = dal.Login(criteria.Username, criteria.Password);
                }
            }

BUT I GOT AN ERROR THAT SAID :
DataPortal.Fetch failed (Database name not found in config file (Resto_DB))

I hope anyone can help me about my problem
Thanks a lot before about respond of my post...

Stefanus




st3fanus replied on Thursday, January 07, 2010

thanks Sergey Barskiy.. that problem has been solved.
But there is another problem that said
Instance Failure , but i'm sure i have write connection string correctly..

I have debug that error an stop when :
private ConnectionManager(string connectionString, string label)
    {
      _label = label;
      _connectionString = connectionString;

      // open connection
      _connection = new C();
      _connection.ConnectionString = connectionString;
      _connection.Open(); /// <---------------------------------------------------- STOP HERE
    }


ERROR MESSAGE : DataPortal.Fetch failed (Instance failure.)

Is there any setting that I've missed ??

Thanks a lot

Stefanus

st3fanus replied on Thursday, January 07, 2010

Hello...

I'm Sorry.. I've found the mistake.. -- My connectionstring still wrong :(
So I have solved this problem.. thank a lot..


Stefanus

Copyright (c) Marimer LLC