Solved

MySql Conncetivity with c#

Posted on 2003-12-04
4
1,389 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
Comment Utility
check this:
http://www.mysql.com/articles/dotnet/
has some good code samples as well
0
 
LVL 2

Expert Comment

by:devaid
Comment Utility
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
Comment Utility
<%@ 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
Comment Utility
The code was taken from the Quickstart Examples.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Article by: Ivo
Anonymous Types in C# by Ivo Stoykov Anonymous Types are useful when  we do not need to follow usual work-flow -- creating object of some type, assign some read-only values and then doing something with them. Instead we can encapsulate this read…
Introduction                                                 Was the var keyword really only brought out to shorten your syntax? Or have the VB language guys got their way in C#? What type of variable is it? All will be revealed.   Also called…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

772 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now