Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

MySql Conncetivity with c#

Posted on 2003-12-04
4
Medium Priority
?
1,401 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:
Fahad Mukhtar earned 375 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: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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 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…
Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…
Suggested Courses

824 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