Καλώς ορίσατε στο dotNETZone.gr - Σύνδεση | Εγγραφή | Βοήθεια
σε

 

Αρχική σελίδα Ιστολόγια Συζητήσεις Εκθέσεις Φωτογραφιών Αρχειοθήκες

Χρήση typed dataset-based DAL σε ASP.NET (Connection string - User Settings Scope problem)

Îåêßíçóå áðü ôï ìÝëïò cap. Τελευταία δημοσίευση από το μέλος cap στις 20-01-2007, 17:29. Υπάρχουν 3 απαντήσεις.
Ταξινόμηση Δημοσιεύσεων: Προηγούμενο Επόμενο
  •  20-01-2007, 13:41 23794

    Χρήση typed dataset-based DAL σε ASP.NET (Connection string - User Settings Scope problem)

    Εχω δημιουργήσει ένα DAL (Class Library) το οποίο περιέχει μόνο Typed Datasets. Αυτό το χρησιμοποιώ σε μια Windows Forms εφαρμογή.

    Θέλοντας να αποφύγω να φτιάξω παραπλήσιο DAL για ένα Web Site που εκμεταλλεύεται την ίδια database, σκέφτηκα να χρησιμοποιήσω το DAL που ήδη έχω φτιάξει. (Σημείωση: Πρόκειται για DNN module αλλά σε αυτό το context δεν έχει - πιστεύω - ιδιαίτερη σημασία).

    Κανω λοιπόν reference στο DAL και αυτό μπαίνει κανονικότατα στο BIN folder. Ομως, όταν πάω να το τρέξω παίρνω runtime exception με μήνυμα "The current configuration system does not support user-scoped settings.".

    Ψάχνοντας λίγο κατάλαβα οτι το πρόβλημα βρίσκεται στο πώς έχω φτιάξει το connection string του DAL μου από την Windows Forms εφαρμογή. Χρησιμοποιώντας το namespace My (VB.NET), έχω δημιουργήσει το γνωστό [ονομα dll μου].My.MySettings.ConnectionString. Αυτό όμως φαίνεται οτι ανήκει στην κατηγορία των User Settings. Προφανώς λοιπόν όταν τρέχω το ίδιο πράγμα κάτω από ASP.NET φωνάζοντας τα objects (datasets/tableadapters του), δεν μπορεί να το βρεί.

    Δοκίμασα να βάλω το connection string με την ίδια ονομασία στο Web.Config της εφαρμογής. (Καποιος, σε κάποιο forum, το πρότεινε). Δεν περίμενα να δουλέψει, και φυσικά δεν δούλεψε.

    Πώς θα μπορούσα να αλλάξω λοιπον τον τρόπο που καθορίζω τα settings έτσι ωστε να είναι προσπελάσιμο το connection String μου και από το Web; Η default συμπεριφορά του dataset designer είναι να δημιουργεί connection string στα user-scoped settings. Εναλλακτικά, τι άλλο μου έχει ξεφύγει;

    Warning: Ειμαι (σχεδόν) noob στο νέο σχήμα αποθήκευσης settings 4 επιπέδων του ASP.NET 2.0, οπότε πείτε τα μου λίγο πιό επεξηγηματικά :)

     

     


    Σωτήρης Φιλιππίδης

    DotSee Web Services

    View Sotiris Filippidis's profile on LinkedIn

    DotNetNuke them!
  •  20-01-2007, 14:02 23797 σε απάντηση της 23794

    Απ: Χρήση typed dataset-based DAL σε ASP.NET (Connection string - User Settings Scope problem)

    Ισως αυτή η ερώτηση που έγινε εδώ: http://www.theserverside.net/discussions/thread.tss?thread_id=37108#211245 συνοψίζει ακόμα πιό καλά το τι θέλω τελικά να κάνω (αν σας μπέρδεψα με τα παραπάνω):

    Αντιγράφω:

    How to change the ConnectionString for an auto generated typed dataset if this dataset is in a separate dll. Does anybody know a solution? We have WinForm exe, that uses several DLLs, inside those DLLs we have auto-generated DataSets. And Datasets have Connection string inside Stettings.settings. We want them to use connection string from app.config in main WinForm App; and we do not want to have many places for connection string. Any Input from anybody? Thank you

    Και επίσης εδώ: http://www.theserverside.net/discussions/thread.tss?thread_id=37108#203046

    Αντιγράφω:

    I've been playing with the new DataSet for a few days now and MS has done a wonderful job with their overhaul in this area of VS. I especially like the Data Adapter designing capabilities here.
     
    Is there a way to use this without VS baking the connection string directly into the code it generates for you? It gives you a few options when you first create a new adapter, but somehow mine always end up in the Setting.settings file. It appears the designer itself needs a connection to the database to do it designing, so it requires that a connstring be baked in (via settings.settings, app.config, or hardcoding). I don't want my connstring anywhere in that code (hardcoded nor configured).
     
    Ignoring that for a minute, it seems that if you want to keep your connection outside of the adapter, you're forced to set the .Connection property on the adapter. I'm feeling some conflict architecturally here with the Enterprise Library to the DAL. I don't want there to be any confusion at design time, compile time, or runtime where my connstring is (singular). On top of that, because there is no common base class or interface for class adapters that it generates, I can't implement any kind of factory for these adapters. Call me a centralization zealot, but I don't want my connection string in multiple places, and if I must set the .Connection property myself, I want to only do it in one place.
     
    I'm foreseeing a future filled with code reviews hunting for the proper setting of the .Connection property. Or worse... dev's coding and unit testing against the wrong version of the database schema because the code is using the wrong connstring baked into the adapter
     
    Is there a better way to leverage this awesome new designer without shooting yourself in the foot?


    Σωτήρης Φιλιππίδης

    DotSee Web Services

    View Sotiris Filippidis's profile on LinkedIn

    DotNetNuke them!
  •  20-01-2007, 17:23 23802 σε απάντηση της 23797

    Απ: Χρήση typed dataset-based DAL σε ASP.NET (Connection string - User Settings Scope problem)

    Σωτήρη, ελπίζω να σε βοηθήσουν:


    http://www.velocityreviews.com/forums/t237187-the-current-configuration-system-does-not-support-userscoped-settings.html
    http://blogs.msdn.com/rprabhu/articles/433979.aspx


    Angelos Xipolias

    Xelixis.Net
    In .Net we Trust
  •  20-01-2007, 17:29 23803 σε απάντηση της 23802

    Απ: Χρήση typed dataset-based DAL σε ASP.NET (Connection string - User Settings Scope problem)

    Αγγελε ευχαριστώ. Δυστυχώς όμως αυτά δεν βοηθούν γιατί ναι μεν εξηγούν την ιστορία (τα είχα ήδη δει πριν γράψω το post και τα δυο) αλλά δεν μας δίνουν μια λεπτομερή εξήγηση του τι μπορούμε να κάνουμε.
    Σωτήρης Φιλιππίδης

    DotSee Web Services

    View Sotiris Filippidis's profile on LinkedIn

    DotNetNuke them!
Προβολή Τροφοδοσίας RSS με μορφή XML
Με χρήση του Community Server (Commercial Edition), από την Telligent Systems