Denaes Posted April 27, 2004 Posted April 27, 2004 How do you create classes that follow the dot notation? Rather than have a seperate class unto itself for each table in my database (each class triggers stored procedures in my access database) and have it inherit the db class, I'd rather still have it inherit the db class (which has procedures which shorten my insert, update & select triggers substantually), but also be accessed through the db class as well. What I have now: Customer CustomerStatus CustomerType MiscSelects State Each class consists of an Update, Insert & Select method (in some cases, many selects) as well as a private function for setting and returning each column as a oledbparameter, which is only accessed internally. Each also accesses two methods from the db class for selects and update/inserts. What I'd rather have: db.Customer db.CustomerStatus db.CustomerType db.MiscSelects db.State It's probobly something easy, but I don't even know what it's called, let alone how to figure it out. Quote
wessamzeidan Posted April 27, 2004 Posted April 27, 2004 You just have to create objects of type Customer, CustomerStatus, CustomerType, MiscSelects and State in your db class Quote Proudly a Palestinian Microsoft ASP.NET MVP My Blog: wessamzeidan.net
Denaes Posted April 27, 2004 Author Posted April 27, 2004 Create public classes of Customer, MiscSelect, State, etc within db? Thought I'd tried that, but I'll try that again. Thanks :) Quote
travisowens Posted April 29, 2004 Posted April 29, 2004 If these methods aren't in a seperate Class file, then add a new class file to your project now. In that file change the namespace to db and then put your methods in there. Now you can type "db." and use intellisense to access your methods. Make sure you set these methods as public. I'm also new to VS but I've been using this method to get access to glabol like data such as a list of Control.Text default values, application version numbers, contact info, and other stuff that can/might change and I don't want to put in some random place as the code. If you want a full code example here ya go using System; using System.IO; namespace Globals { public class ProgramDetails { public static string ContactEmail = "author@somewhere.com"; public static string ContactPhone = "1.555.555.5555"; public static string ContactName = "John Doe"; public static string ContactCompany = "Coders Int"; public static string CopyrightDate = "2004"; public static string AppName = "SomeAppName"; } public class FileNames { public static string AppSettings = "settings.xml"; } public class StoredProcedures { public static string GetAllUsers = "ups_GetAllUsers"; } } And in my app I just just Globals.FileNames.AppSettings to get that filename. Quote Experience is something you don't get until just after the moment you needed it
Arch4ngel Posted April 29, 2004 Posted April 29, 2004 You can make class within class. If it's what you wanted to know. Create a db class and Copy/Paste the class that you want to be inside of it. That's all. Quote "If someone say : "Die mortal !"... don't stay to see if he isn't." - Unknown "Learning to program is like going out with a new girl friend. There's always something that wasn't mentioned in the documentation..." - Me "A drunk girl is like an animal... it scream at everything like a cat and roll in the grass like a dog." - Me after seeing my girlfriend drunk and some of her drunk friend. C# TO VB TRANSLATOR
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.