smoothcrim Universal Magnetic! 18966 Posts user info edit post |
So I'm completely new to .net so forgive me if this is trivial but I googled for a while.
long story short, we have a large library of vm's. users weren't properly describing what was in the image (unenforced freeform user supplied text = bad) so I wrote a tool that scans the image and creates a webpage detailing what's inside it. there are still some items useful in describing the image that cannot be programmatically be determined.
I want to let users add tags to the auto generated webpages. the tags come from databases owned by their divisions. each division has a completely different db implementation.
I'm trying to write an ajax control that based on the division the user is part of, populates a checkbox treeview with tags that they can apply (eliminates the free form and unenforced uniformity). How do I make an abstract connection to accomplish this? since I can't make the connection object static (that I know of) on creation, I effectively have to have 3 db connection objects at all time and then I have to do a lot of code replication and such.
[Edited on October 5, 2009 at 4:29 PM. Reason : trying to avoid importing all their data into my local db] 10/5/2009 4:26:35 PM |
qntmfred retired 40726 Posts user info edit post |
make 3 different connection strings and initialize your db connection with the correct one based on the user
[Edited on October 5, 2009 at 4:57 PM. Reason : what data access framework are you using btw?]
a little bit more complicated (but more in line with best practices) is to create an interface and then have different implementations of that interface for each user type.
interface ITaggable { public IEnumerable GetTags(String username); }
public class AdminService : ITaggable { public IEnumerable GetTags(string username) { String connectionString = String.Empty; // = System.Configuration.ConfigurationManager.ConnectionStrings["AdminConnectionString"] IEnumerable tags = new List();
using (SqlConnection conn = new SqlConnection(connectionString)) { // blah blah blah }
return tags; } }
[Edited on October 5, 2009 at 5:09 PM. Reason : .]10/5/2009 4:56:19 PM |
smoothcrim Universal Magnetic! 18966 Posts user info edit post |
yeah, I decided on an abstract class a few minutes ago. right now I just have 3 structs (one for oracle, one for mysql, and one for mssql) and then based on the parameter given at launch I load data from the struct with the proper methods just with an instantiated abstract class.
I'm definitely up for looking at other people's code though, so throw it up. 10/5/2009 5:12:24 PM |