Iron Speed Technical Forums
Register Latest Topics
 
 
 


Reply
  Author   Comment  
anr_1204

Registered:
Posts: 17
Reply with quote  #1 
Hello,

I was wondering for this for a while now, I cannot still figure out how can I retrieve the current connectionString. Just to give you a brief, my connectionName changed dynamically depending on the user logged in, I modified the ApplicationSettings.vb in BaseClasses.

So, Ideally, I need some sort of this code so I can pass certain sqlquery on the fly.

Code:
SqlConnection dbconn = new SqlConnection();

dbConn.ConnectionString = BaseClasses.Configuration.ApplicationSettings.Current.ConnectionName

SqlCommand cmd = new sqlCommand("select * from table", dbconn);


At the time being, what I did as alternative was, store the full conenctingString into Session.

Any idea?

Alfred

__________________
Alfred Roa
miles

Avatar / Picture

MVP Consultant
Registered:
Posts: 1,655
Reply with quote  #2 
Do you only have the one database configured in your application?  If so, then retrieving the current database connection should be as simple as:

Dim myConnnection as Stsring = BaseClasses.Configuration .ApplicationSettings.Current.GetConnectionString ("DatabaseKMS1")

where "DatabaseKMS1" represents the name of the connection as found in web.config under the connectionStrings area.


HTH,


__________________
Miles Gibson, MScIS
Iron Speed MVP
Senior Consultant, Principal
Milestone Software Inc.

http://www.ironspeedmvp.com\localizer 
Email: miles@milestone.ca
Milestone Localizer: Full Localization for your Iron Speed applications!
anr_1204

Registered:
Posts: 17
Reply with quote  #3 
Miles, thanks for the reply but that won't work at all. I have multiple databases, which are mapped to users. Every user login is connected to that DB, the DB nor the connection string is determined upon the user log on.

In case you wondered how, I have modified the GetConnectionString() method in BaseClasses.ApplicationSettings to switch connectionName dynamically.

Having said that, I need to retrieve the CURRENT connectionSTring/name from .aspx.cs/vb code-behind.

Thanks

__________________
Alfred Roa
anr_1204

Registered:
Posts: 17
Reply with quote  #4 
I had figured this out; and it's been working without a miss.

Alfred

__________________
Alfred Roa
mhweiss

Avatar / Picture

MVP Consultant
Registered:
Posts: 569
Reply with quote  #5 

Hello
What solution did you come up with?
Best Regards,
Michael


__________________
michael@occasiosystems.com
http://www.occasiosystems.com
meryls

Registered:
Posts: 14
Reply with quote  #6 
Anyone know how to get the just the database name (not the whole connection string) out of the web.config for use in stored procedure call?  My users all have different dataabases.  Thanks!
JimiJ

Avatar / Picture

MVP Developer
Registered:
Posts: 1,927
Reply with quote  #7 
I used to store the connectionstring info along with user's credentials in a table for fully dynamic users-db operation. We've been doing this since ISD 5.0.


Cheers,
Jimi J

__________________

  Jaime Jegonia
[jts_logo]

Iron Speed MVP Developer
 

". . . and whoever sows generously will also reap generously" 2 Cor 9:6

Previous Topic | Next Topic
Print
Reply

Quick Navigation:

Download Iron Speed Designer

Terms of Service Privacy Statement