Solved

MySql Conncetivity with c#

Posted on 2003-12-04
4
1,395 Views
Last Modified: 2010-04-16
Hello
I am using ASP.Net with c# i am trying to connect with MySql Database using C# with ADO.Net. Can any body help me how to do that? If possibile with example.
0
Comment
Question by:mohitnigam
  • 2
4 Comments
 
LVL 19

Accepted Solution

by:
Desp earned 125 total points
ID: 9880706
check this:
http://www.mysql.com/articles/dotnet/
has some good code samples as well
0
 
LVL 2

Expert Comment

by:devaid
ID: 9881893
Firstly you will need the ODBC Data Providor for .NET found here: http://www.microsoft.com/downloads/details.aspx?displaylang=en&FamilyID=6CCD8427-1017-4F33-A062-D165078E32B1

Then add the following to your using list:
using Microsoft.Data.Odbc;

Then heypresto just work with ODBC objects instead of olebe and sqlclient.

I found this following link very helpful: http://www.devshed.com/Server_Side/MySQL/ODBC/
0
 
LVL 7

Expert Comment

by:jj819430
ID: 9885257
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SqlClient" %>

<html>
<script language="C#" runat="server">

    protected void Page_Load(Object sender, EventArgs e)
    {
        SqlConnection myConnection = new SqlConnection("server=(local)\\NetSDK;database=pubs;Trusted_Connection=yes");
        SqlDataAdapter myCommand = new SqlDataAdapter("select * from Authors", myConnection);

        DataSet ds = new DataSet();
        myCommand.Fill(ds, "Authors");

        MyDataGrid.DataSource=ds.Tables["Authors"].DefaultView;
        MyDataGrid.DataBind();
    }

</script>

<body>

  <h3><font face="Verdana">Simple Select to a DataGrid Control</font></h3>

  <ASP:DataGrid id="MyDataGrid" runat="server"
    Width="700"
    BackColor="#ccccff"
    BorderColor="black"
    ShowFooter="false"
    CellPadding=3
    CellSpacing="0"
    Font-Name="Verdana"
    Font-Size="8pt"
    HeaderStyle-BackColor="#aaaadd"
    EnableViewState="false"
  />

</body>
</html>

Is one way to do it.
If you want the basics you can see them at...
http://samples.gotdotnet.com/quickstart/aspplus/

Under Server Side Data Access
0
 
LVL 7

Expert Comment

by:jj819430
ID: 9885263
The code was taken from the Quickstart Examples.
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question