Hot File

C# ASP.NET MySQL Connection Tutorial with MySQL Connector

View: 2209    Dowload: 0   Comment: 0   Post by: naruto  
Author: none   Category: MySQL   Fields: Computers - Technology

0 point/3 review File has been tested

In order to connect to MySQL Server with .NET in C# or ASP.NET: You need to download MySQL Connector/Net . After you add a reference to your project, it is probably in C:\Program Files\MySQL\MySQL Connector Net 5.0.7\Binaries\.NET 2.0 folder, add the MySql.Data.dll file as a reference. Make your connection string, the following code will shows a standard MySQL connection string.

Introduction

In order to connect to MySQL Server with .NET in C# or ASP.NET:

using MySql.Data.MySqlClient;
public static string GetConnectionString()
{
  string connStr = String.Format("server={0};user id={1}; password={2};" + 
    "database=yourdb; pooling=false", "yourserver",
    "youruser", "yourpass");

  return connStr;
}
MySql.Data.MySqlClient.MySqlConnection mycon = 
  new MySqlConnection( GetConnectionString());
if(mycon .State != ConnectionState.Open)
try
{
  mycon .Open();
}
catch (MySqlException ex)
{
  throw (ex);
}
  • You need to download MySQL Connector/Net .
  • After you add a reference to your project, it is probably in C:\Program Files\MySQL\MySQL Connector Net 5.0.7\Binaries\.NET 2.0 folder, add the MySql.Data.dll file as a reference.
  • Make your connection string, the following code will shows a standard MySQL connection string.
  • Then create an instance from MySql.Data.MySqlClient.MySqlConnection as shown below.
  • Then try to open the MySqlConnection.

So simple as you see, It is always better to do this in data access layer also called DAL.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

C# ASP.NET MySQL Connection Tutorial with MySQL Connector

C# ASP.NET MySQL Connection Tutorial with MySQL Connector Posted on 21-03-2014  In order to connect to MySQL Server with .NET in C# or ASP.NET: You need to download MySQL Connector/Net . After you add a reference to your project, it is probably in C:\Program Files\MySQL\MySQL Connector Net 5.0.7\Binaries\.NET 2.0 folder, add the MySql.Data.dll file as a reference. Make your connection string, the following code will shows a standard MySQL connection string. 5/10 2209

Comment:

To comment you must be logged in members.

Files with category

  • SQL Query to Find Nth Highest Salary of Employee with java

    View: 280    Download: 0   Comment: 0   Author: none  

    SQL Query to Find Nth Highest Salary of Employee with java

    Category: MySQL
    Fields: Other

    0/0 review
    This is a very common interview question if you are going for the role at junior level. Most of the people learn it character by character, but few understand how this query works.

  • World OOP With PHP and MySQL

    View: 1040    Download: 0   Comment: 0   Author: none  

    World OOP With PHP and MySQL

    Category: MySQL
    Fields: Other

    0.32142857142857/14 review
    Setting up the skeleton of our class is fairly simple once we figure out exactly what we need.

  • How to Build a Newsletter System With PHP and MySQL

    View: 1324    Download: 0   Comment: 0   Author: none  

    How to Build a Newsletter System With PHP and MySQL

    Category: MySQL
    Fields: Other

    1.125/4 review
    When starting any project, I like to layout the folders before I start coding, so lets do that now.

  • Top 20+ MySQL Best Practices that can not be ignored

    View: 979    Download: 0   Comment: 0   Author: none  

    Top 20+ MySQL Best Practices that can not be ignored

    Category: MySQL
    Fields: Other

    1.6666666666667/3 review
    Database operations often tend to be the main bottleneck for most web applications today.

  • Create a PHP/MySQL Powered Forum from Scratch

    View: 1149    Download: 0   Comment: 0   Author: none  

    Create a PHP/MySQL Powered Forum from Scratch

    Category: MySQL
    Fields: Other

    1.5/3 review
    In this tutorial, we're going to build a PHP/MySQL powered forum from scratch.

  • Triggers Introduction to MySQL

    View: 328    Download: 0   Comment: 0   Author: none  

    Triggers Introduction to MySQL

    Category: MySQL
    Fields: Other

    1.6666666666667/3 review
    I would guess, even armed with this knowledge, that a good many of you are not taking advantage of triggers with MySQL.

  • How to Stored Procedures in MySQL 5

    View: 325    Download: 0   Comment: 0   Author: none  

    How to Stored Procedures in MySQL 5

    Category: MySQL
    Fields: Other

    2.25/2 review
    MySQL 5 introduced a plethora of new features - stored procedures being one of the most significant. In this tutorial, we will focus on what they are, and how they can make your life easier.

  • The strength of the PDO and. MySQLi: Which Should You Use?

    View: 330    Download: 0   Comment: 0   Author: none  

    The strength of the PDO and. MySQLi: Which Should You Use?

    Category: MySQL
    Fields: Other

    1.5/3 review
    When accessing a database in PHP, we have two choices: MySQLi and PDO. So what should you know before choosing one?

 
Newsletter Email

File suggestion for you

File top downloads

logo codetitle
Codetitle.com - library source code to share, download the file to the community
Copyright © 2015. All rights reserved. codetitle.com Develope by Vinagon .Ltd