Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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.

Posted

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.

Experience is something you don't get until just after the moment you needed it
Posted

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.

"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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...