Changing initialcatalog in webservice

Posts   
 
    
Posts: 42
Joined: 22-Jan-2007
# Posted on: 29-Jan-2010 15:53:02   

Using: * LLBLGEN Pro 2.6 Final August 18th 2008 * NET20 ORM Runtime library 2.6.8.819 * Silverlight application, WebService and Data Transfer Objects created with the LLBLGEN DTO templates.

Problem: I am trying to change the selected database from within the webservice application. After some struggling (web.config, sqlServerCatalogNameOverwrites, publickeytoken, etc) I managed to do so. But ... only in the sub New of the webservice class:

Public Sub New() Dim sConnectionString As String = "data source=MYSERVER;initial catalog=MYOTHERDATABASE;User ID=MYUSER;Password=MYPWD;persist security info=False;packet size=4096" myDA = New QBODTO.DatabaseSpecific.DataAccessAdapter(sConnectionString) End Sub

What I want is to pass the new databasename from my Silverlight app to the webservice app in order to switch to another database. Tried this via a web method, but it doesn't seem to work that way: <WebMethod()> _ Public Function LogIn(ByVal sDatabase As String) As Boolean

    Dim builder As New System.Data.SqlClient.SqlConnectionStringBuilder(myDA.sConnectionString)
     builder.InitialCatalog = sDatabase

    myDA.ConnectionString  = builder.ConnectionString

End Function 
daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 29-Jan-2010 18:58:53   

You should use CatalogNameOverwriteHashtable for that:

CatalogNameOverwriteHashtable newCatalogName= new CatalogNameOverwriteHashtable();
     newCatalogName.Add("OldCatalogName", "NewCatalogName");

Then pass it to the DataAccessAdapter CTor.

David Elizondo | LLBLGen Support Team