Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8318117
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T21:50:56+00:00 2026-06-08T21:50:56+00:00

Let’s say I already have a correctly formed connection string named ‘ myConn ‘

  • 0

Let’s say I already have a correctly formed connection string named ‘myConn‘ in my Web.config. The database is on a different server and is MySQL. How do I connect to this database in my ASP.NET web app?

What I tried:
I tried installing the ‘ADO.NET C# DbContext Generator With WCF Support‘ but this blew up in my face with the error message ‘The assembly reference “System.Data.Entity” could not be added to the project. This wizar will continue to run, but the resulting project may not build properly.‘

Notes:

  • Using Visual Studio 2010 (Version 10.0.40219.1 SP1Rel)
  • Using .NET Framework 2.0
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T21:50:58+00:00Added an answer on June 8, 2026 at 9:50 pm

    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 😛

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Let's say that I have a SQLite database that I create in a separate
Let's say I have a string like this: var str = /abcd/efgh/ijkl/xxx-1/xxx-2; How do
Let's say I have the following classes : public class MyProductCode { private String
Let's say I have the string: hello world; some random text; foo; How could
Let's say I have two assemblies: BusinessLogic and Web. BusinessLogic has an application setting
Let's say I have a class Base with a single member message (String). Another
Let's say I have a WordPress installation, with a page named About. If I
Let's say I don't have photoshop, but I want to make pattern files (.pat)
Let's say I have a method in java, which looks up a user in
Let me explain best with an example. Say you have node class that can

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.