You are here : numohosts | professional business web hosting Dedicated Servers Collocation Solutions
professional business web hosting from numoHosts professional business web hosting dedicated servers collocation solutions
Connecting to database through asp and php

Select your internet browser for some handy instructions to get the most from your internet browser.

If you want to connect to the database, please look at the point indicating your scripting language:
  • PHP

  • $dbuser="username"; //your username
    $dbpass="password"; //password for the database
    $dbname="mydata"; //the name of the database
    $chandle = mysql_connect("localhost", $dbuser, $dbpass)
    or die("Connection Failure to Database");
    echo "Connected to database server
    "; //if you connect to the database, it shows a message, that you were successful in connecting
    mysql_select_db($dbname, $chandle) or die ($dbname . " Database not found." . $dbuser);
    echo "Database " . $database . " is selected"; //this text is not necessary
    mysql_close($chandle); //this line you should write at the end, when you you do not need any connection to database anymore.

    Text after the sign // may be deleted, because it does not have any effect on the code.

  • ASP

  • Dim ServerName ‘put here you server name (address where the database is placed)
    Dim DatabaseName ‘put here the database name
    Dim Username ‘valid username for the database
    Dim Password ‘valid password for the database
    Set Conn = Server.CreateObject("ADODB.Connection")
    Conn.Open "Provider=sqloledb;Data Source=ServerName;Initial Catalog=DatebaseName;User Id=Username;Password=Password;"


    strSql = "SELECT FieldName FROM TableName"

    Set rs = Conn.Execute(strSql)

    If rs.eof Then
    Response.write("No records returned")
    End If

    do until rs.eof
    Response.write(rs("FieldName") & "
    ")
    rs.movenext
    loop

    Conn.Close ‘write that whenever you want to close the connection
    Set Conn = Nothing


    More information about sql you can get by clicking on the provided link: http://dev.mysql.com/doc/.

 
 
   Email to a friend  Terms of Use  Privacy Policy  
   Add this page to your Favorites  Make this page your home page  

 | © 1996 - 2010 part of numoGroup |
 | w : numoVision | numoWorks |
 | t : +44 (0) 845 092 0790 | f : +44 (0) 845 092 0797 |
 | e : info@numogroup.net |
 | Numo Ltd registered in England & Wales : 04970960 |

 
 Latest News
UPGRADED ANTI-SPAM FILTERING TECHNOLOGY
Our email service now includes additional new and highly respected Anti-Spam...


 read more...
 
 
 Testimonials
A very helpful guy answered promptly and bent over backwards to help resolve the situation

 read more...