Solved

MySql Conncetivity with c#

Posted on 2003-12-04
4
1,396 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction This article series is supposed to shed some light on the use of IDisposable and objects that inherit from it. In essence, a more apt title for this article would be: using (IDisposable) {}. I’m just not sure how many people would ge…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …
Suggested Courses

752 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