+ Reply to Thread
Results 1 to 2 of 2

Thread: Connect to a remote database and display data in gridview in ASP

  1. #1
    Junior Member
    Join Date
    Jan 2012

    Connect to a remote database and display data in gridview in ASP

    I'd like to connect to a database and display the data into a gridview , i am new to ASP so i don't know to do that.

    Could you show me at least the steps ?
    Last edited by cross; 11-02-2012 at 01:19 PM.

  2. #2
    Junior Member
    Join Date
    May 2012
    In ASP.net you can access a SQL or MySql database and display it`s data using a GridView control .
    I have been using the Wamp server as a local server and my ip will be : and i have created a test database
    If you do not know about wamp . HERE is a quick article about it

    Steps :
    1- download the MySQL connector library to allow a remote access to database
    2- import the library into project and use the namespace
    3- insert a gridview control into page
    4- use sql query to retrieve data

    1- download the MySQL connector library from HERE The latest version is 6.3.9 , mine is 5.2.7 and it works fine.
    2- Import the Library by adding a new reference and browse for it. and use these namespace :
    using MySql.Data.MySqlClient;
    using System.Data;
    3- drage a GridView and drop it into page
    4- on form load event use the follow code :
                GridView1.DataSourceID = null;
                MySqlConnection c = new MySqlConnection("server=; database=Test_Datavase; uid=root; pwd=; Pooling=false;");
                DataSet ds = new DataSet();
                // MySqlDataAdapter for commands
                MySqlDataAdapter msd = new MySqlDataAdapter();
                // simple sql query
                msd.SelectCommand = new MySqlCommand("SELECT * FROM professor", c);
                // open connection
                // fill the data into dataset
                // i already put a datagrid on my application
                GridView1.DataSource = ds.Tables[0];
                // execute query
                // close connection

+ Reply to Thread

Tags for this Thread


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts