connecting to mysql using asp.net - c#

Discussion in 'ASP .Net' started by Paradox Synthesist, Apr 29, 2007.

  1. hi,
    i am a newbie to asp.net and have started learning mainly from
    websites. i have a question which IS very silly and trivial.

    http://msdn2.microsoft.com/en-us/li...c.odbcconnectionstringbuilder.dsn(VS.80).aspx

    i looked through this url to see how could i connect to a mysql
    database...where does the dsn figure out? why do i need to give it? i
    cant see any dsn specified anywhere on the database control panel. i
    am a newbie to this thing. all i could figure out was the connection
    string part:

    http://dev.mysql.com/tech-resources/articles/dotnet/
    .....................[
    string MyConString = "DRIVER={MySQL ODBC 3.51 Driver};" +
    "SERVER=localhost;" +
    "DATABASE=test;" +
    "UID=venu;" +
    "PASSWORD=venu;" +
    "OPTION=3";

    OdbcConnection MyConnection = new OdbcConnection(MyConString);
    MyConnection.Open();

    The above one uses DSN-less connection, if you have a MyODBC DSN
    defined already then you can just use "DSN=dsn_name" as the connection
    string i.e.

    OdbcConnection MyConnection = new OdbcConnection("DSN=myodbc3-
    test");
    MyConnection.Open();
    ]....................

    but the dsn part is something that is baffling me. moreover at places
    it is said that i need to change my webconfig file. is it necessary to
    do so?
    Could you tell me the procedure of connecting to a mysql database
    using the odbc driver and inserting a row in a table; all the
    procedures involved?
     
    Paradox Synthesist, Apr 29, 2007
    #1
    1. Advertising

  2. Paradox Synthesist

    Mark Rae Guest

    Mark Rae, Apr 29, 2007
    #2
    1. Advertising

  3. Paradox Synthesist

    David Guest

    You can use DSN or DSNLess connections.

    The DSNless is the one where you define all the parameters to connect to the
    database. a DSN is one you have created on the ODBC administrator in control
    panel (of windows).

    You can put your connection string (either DSN or DSNLess) in your
    web.config or in your code.

    In .NET 1.1, you need...

    using System.Data.Odbc;

    In your code, you just add the data like you would any database. There are
    loads of examples on the net for this.

    --
    Best regards,
    Dave Colliver.
    http://www.AshfieldFOCUS.com
    ~~
    http://www.FOCUSPortals.com - Local franchises available
    "Paradox Synthesist" <> wrote in message
    news:...
    > hi,
    > i am a newbie to asp.net and have started learning mainly from
    > websites. i have a question which IS very silly and trivial.
    >
    > http://msdn2.microsoft.com/en-us/li...c.odbcconnectionstringbuilder.dsn(VS.80).aspx
    >
    > i looked through this url to see how could i connect to a mysql
    > database...where does the dsn figure out? why do i need to give it? i
    > cant see any dsn specified anywhere on the database control panel. i
    > am a newbie to this thing. all i could figure out was the connection
    > string part:
    >
    > http://dev.mysql.com/tech-resources/articles/dotnet/
    > ....................[
    > string MyConString = "DRIVER={MySQL ODBC 3.51 Driver};" +
    > "SERVER=localhost;" +
    > "DATABASE=test;" +
    > "UID=venu;" +
    > "PASSWORD=venu;" +
    > "OPTION=3";
    >
    > OdbcConnection MyConnection = new OdbcConnection(MyConString);
    > MyConnection.Open();
    >
    > The above one uses DSN-less connection, if you have a MyODBC DSN
    > defined already then you can just use "DSN=dsn_name" as the connection
    > string i.e.
    >
    > OdbcConnection MyConnection = new OdbcConnection("DSN=myodbc3-
    > test");
    > MyConnection.Open();
    > ]....................
    >
    > but the dsn part is something that is baffling me. moreover at places
    > it is said that i need to change my webconfig file. is it necessary to
    > do so?
    > Could you tell me the procedure of connecting to a mysql database
    > using the odbc driver and inserting a row in a table; all the
    > procedures involved?
    >
     
    David, Apr 29, 2007
    #3
  4. On Sun, 29 Apr 2007 21:49:25 +0100, David wrote:

    > You can use DSN or DSNLess connections.
    >
    > The DSNless is the one where you define all the parameters to connect to the
    > database. a DSN is one you have created on the ODBC administrator in control
    > panel (of windows).
    >
    > You can put your connection string (either DSN or DSNLess) in your
    > web.config or in your code.
    >
    > In .NET 1.1, you need...
    >
    > using System.Data.Odbc;
    >
    > In your code, you just add the data like you would any database. There are
    > loads of examples on the net for this.


    Where possible, try and use MySQL native .NET provider for better
    performance
    --
    Bits.Bytes
    http://bytes.thinkersroom.com
     
    Rad [Visual C# MVP], May 1, 2007
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Nikola Skoric

    connecting to mysql through DBI problem

    Nikola Skoric, Jan 14, 2004, in forum: Perl
    Replies:
    0
    Views:
    741
    Nikola Skoric
    Jan 14, 2004
  2. Philip Townsend

    connecting to mysql

    Philip Townsend, Jan 21, 2004, in forum: ASP .Net
    Replies:
    3
    Views:
    418
    Ken Cox [Microsoft MVP]
    Jan 22, 2004
  3. =?Utf-8?B?S2VubmV0aCBQ?=

    Connecting to MySql.Data.MySqlClient namespace

    =?Utf-8?B?S2VubmV0aCBQ?=, Dec 15, 2004, in forum: ASP .Net
    Replies:
    2
    Views:
    9,594
    Patrick Olurotimi Ige
    Jan 13, 2005
  4. Rajesh A via DotNetMonster.com

    MySQL Connecting Problume

    Rajesh A via DotNetMonster.com, Aug 5, 2005, in forum: ASP .Net
    Replies:
    4
    Views:
    457
    Mark Rae
    Aug 8, 2005
  5. dave
    Replies:
    4
    Views:
    1,394
    Steve Holden
    Nov 18, 2010
Loading...

Share This Page