Probably a basic question but...

I have an windows application comprising several forms with a SQL Server database in the background. From several of the forms, I keep needing to run the same method, so instead of repeating code in each form, I want to put this (repeated) method in a separate class and access it from there.

1. Is this the best thing to do?
2. If so, will I need to set up a new database connection to the class (the forms use a dataset and tableadapters, but the new class will not have these)? How do I best do this?

Thanks in advance for any help.

Create a Static Class and make the method static. Then at any time in the application you simply call it [I]Classname[/I].[I]Methodname[/I]([I]parms[/I]); . that easy.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.