On a button click - you will need Event
handling and subscribe to correct events.
to create a new object:
YourClass objc = new YourClass()
to connect to a database:
you need to set up the ConnectionString
correctly and access the database through SqlClient
interfaces (or you can use Linq2Sql
or entity framework or whatever!)
--- edit after OP's comment ---
You can create a new object with name and some id passing the name and id in a text box by actually compiling the source code and loading the assembly dynamically. This is ugly way to do in C#. But here is a way to actually compile an assembly in C# and then run it:
What is the best scripting language to embed in a C# desktop application?