Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > connecting to mysql using asp.net - c#

Reply
Thread Tools

connecting to mysql using asp.net - c#

 
 
Paradox Synthesist
Guest
Posts: n/a
 
      04-29-2007
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/lib...sn(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?

 
Reply With Quote
 
 
 
 
Mark Rae
Guest
Posts: n/a
 
      04-29-2007
"Paradox Synthesist" <> wrote in message
news: oups.com...

> Could you tell me the procedure of connecting to a mysql database
> using the odbc driver


Firstly, can I just ask you why on earth you are even trying to use ODBC...?

http://www.mysql.com/products/connector/net/
http://www.crlab.com/mysqlnet/download.html
http://sourceforge.net/projects/mysqldrivercs/

 
Reply With Quote
 
 
 
 
David
Guest
Posts: n/a
 
      04-29-2007
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: oups.com...
> 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/lib...sn(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?
>



 
Reply With Quote
 
Rad [Visual C# MVP]
Guest
Posts: n/a
 
      05-01-2007
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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Using Python and Connecting to MySQL remotely WITHOUT MySQL installedon local computer dave Python 4 11-18-2010 04:19 AM
using mysql client to read a file to create a table in a database in a mysql server julian Ruby 8 04-06-2006 10:29 AM
Connecting to MySql.Data.MySqlClient namespace =?Utf-8?B?S2VubmV0aCBQ?= ASP .Net 2 01-13-2005 08:08 AM
connecting to mysql Philip Townsend ASP .Net 3 01-22-2004 12:44 AM
connecting to mysql through DBI problem Nikola Skoric Perl 0 01-14-2004 03:11 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57