connecting to mysql using asp.net - c#

P

Paradox Synthesist

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?
 
D

David

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
 
R

Rad [Visual C# MVP]

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,733
Messages
2,569,439
Members
44,829
Latest member
PIXThurman

Latest Threads

Top