#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2010
    Posts
    59
    Rep Power
    0

    Basics on how to connect with a database


    In PHP you set up a database and table structure using mysql. You have a connection with a username and password; a sql code to be executed and a result.

    How do you do that in an asp.net framework?

    Especially the connection.
  2. #2
  3. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2012
    Location
    USA
    Posts
    33
    Rep Power
    0
    <%@ Import Namespace=""System.Data.OleDb"" %>
    <script runat=""server"">
    Sub Page_Load
    Dim dbconn
    dbconn=New OleDbConnection (""Provider=Microsoft.Jet.OLEDB.4.0; data source="" & server.mappath (""northwind.mdb""))
    dbconn.Open ()
    end sub
    </script>
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2012
    Posts
    9
    Rep Power
    0
    Google "ASP.NET Connecting to Database" and check out the Microsoft MSDN page. It provides some pretty straightforward instructions on how to do this.
  6. #4
  7. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2011
    Posts
    18
    Rep Power
    0
    In PHP you set up a database and table structure using mysql. You have a connection with a username and password; a sql code to be executed and a result.
    1. the counter part of mysql (php) is MSSql (.NET) , generally. Although .NET can connect with other databases including mysql. Rest table strucute and sql querires are similar

    2. in .NET as well you have a connection with username and password. you use System.Data.Sql.SqlClient Namespace to create objects of sqlconnection class. one thing though, 90% of the times the mysql database host with php is localhost but in .NET you have to provide the server address. counterpart of localhost is '.'

    3. sql code is same, additionally you can take advantage of stored procedures in MSSql, i guess recent versions of mysql also support stored procedures now.

    4. result in php is a variable and in .NET its DataSet or DataTable.
  8. #5
  9. No Profile Picture
    Permanently Banned
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2012
    Posts
    5
    Rep Power
    0
    Before you can access data in a database, you must create a connection to the database.In PHP, this is done with the mysql_connect() function.
    dapfor .com/en/net-suite/net-grid/tutorial/data-binding

IMN logo majestic logo threadwatch logo seochat tools logo