Assuming ODBC (not the only option), it should just be a matter of:
OdbcConnection conn = new OdbcConnection(connectionString);
conn.Open();
edit: oh, and in case it was getting it from the web.config you were wondering about (probably not, but who knows), that part would be:
string connectionString = System.Configuration.ConfigurationManager.AppSettings["myConn"].ToString(); //ToString here is optional unless you're doing some weirdness in the web.config
Per your request, here's the basics behind obdc data operations:
The following is for a query-type statement:
string command = "SELECT Something FROM SomeTable WHERE SomethingElse = '%" + "@Parameter1" + "%' AND SomethingElseStill LIKE '%" + @Parameter2 + "%' ";
using (OdbcConnection connection = new OdbcConnection(connectionString))
{
OdbcCommand command = new OdbcCommand(command, conn);
command.Parameters.Add("@Parameter1", OdbcType.VarChar, 255);
command.Parameters["@Parameter1"].Value = "SomeString"
command.Parameters.Add("@Parameter2", OdbcType.Int);
int SomeInteger = 1;
command.Parameters["@Parameter2"].Value = SomeInteger;
OdbcDataAdapter adapter = new OdbcDataAdapter(command,con);
DataSet Data = new DataSet();
adapter.Fill(Data);
}
That will take data from your database and shove it into a DataTable object, using the OdbcDataAdapter object. This is not the only way to do it, but it is certainly the most basic. Look at this great answer for a method of converting the result into a list of whatever object you want, using a little bit of reflection. You can also use something like LINQ to map the data to custom classes, but I'll leave that bit to you.
Anyway, here's the same, but with a non-query:
string command = "INSERT INTO SomeTable (column1, column2, column3) VALUES '%" + "@Parameter1" + "%', '%" + "@Parameter2" + "%', '%" + "@Parameter3" + "%' ";
using (OdbcConnection connection = new OdbcConnection(connectionString))
{
OdbcCommand command = new OdbcCommand(command, conn);
command.Parameters.Add("@Parameter1", OdbcType.VarChar, 255);
command.Parameters["@Parameter1"].Value = "SomeString"
command.Parameters.Add("@Parameter2", OdbcType.Int);
int SomeInteger = 1;
command.Parameters["@Parameter2"].Value = SomeInteger;
command.Parameters.Add("@Parameter3", OdbcType.VarChar, 255);
command.Parameters["@Parameter3"].Value = "SomeOtherStringOrSomething";
command.ExecuteNonQuery();
}
Make sure to sanity-check my quotes and stuff, as I wrote it in the StackOverflow editor, not any kind of IDE, so unfortunately I dont get syntax highlighting :P