473,394 Members | 1,700 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

connecting to mysql using asp.net - c#

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?

Apr 29 '07 #1
3 2682
"Paradox Synthesist" <ku**********@gmail.comwrote in message
news:11**********************@p77g2000hsh.googlegr 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/

Apr 29 '07 #2
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" <ku**********@gmail.comwrote in message
news:11**********************@p77g2000hsh.googlegr 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?

Apr 29 '07 #3
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
May 1 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Google Mike | last post by:
After a lot of thought and research, and playing with FreeTDS and InlineTDS, as well as various ODBC connections, I have determined that the fastest and cheapest way to get up and going with PHP on...
0
by: maddunr | last post by:
Hi, I just installed PHP 4.3.9, MySQL 4.0.2 and PHPMyAdmin 2.6.0-pl3 on our intranet server (Win2k3 running IIS). I also have a similar setup on my local machine (http://localhost/phpmyadmin). ...
3
by: kamilla | last post by:
I have a mysql 3.5 server installed on a suse linux 8.1, with address 10.0.0.100. Now I want to access that db from a W2K pc, address 10.0.0.200. I am able to ping 10.0.0.100, but I cannot connect...
2
by: news | last post by:
We currently have our mySQL server on the same box as the Apache server. For security and load balancing, we're going to be moving the mySQL server to another box. We're already using a single...
4
by: CodeImp | last post by:
A simple app I quickly wrote to try getting info from a database. Here is the first part of its code. The rest of the code is irellevant. using System; using System.Data; using...
3
by: Jeremy Dillinger | last post by:
I am trying to design a program that will use data from a MySQL database. Currently all the data is being used with PHP scripts from a website. I am also trying to build a software solution that...
5
by: Ananthu | last post by:
Hi I have done all the codings part for connecting mysql server with java application but when i try to compile,the compilation is successful and during execution i get the following message, ...
8
by: Ananthu | last post by:
Hi I have done all the codings part for connecting mysql with java in eclipse environment. Coding Part: import java.sql.Connection; import java.sql.DriverManager; public class...
8
Vkas
by: Vkas | last post by:
i have a domain www.thesunriseschool.com for connecting the database i am using <?php $sId=session_id(); $uIp=$_SERVER; $time=time(); $date_now=date("d/m/Y", $time);...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.