  | 
            | 
            | 
             | 
         
        
             | 
                       | 
          
            
               
                 <?
	# ติดต่อกับฐานข้อมูล Mysql และ Database 
	$host = "localhost";
	$user= "root";
	$password= "";
	$db = "=ชื่อdatabase";
	mysql_connect($host,$user,$password) or die ( "ไม่สามารถติดต่อฐานข้อมูลได้");
	mysql_select_db($db) or die ("ไม่เลือกฐานข้อมูลได้");
?>                        
               
               | 
             
            
              
			                                
              
                
                     | 
                     | 
                     | 
                 
                
                     | 
                  
                      
                        | Date :
                            2009-11-10 15:07:10 | 
                        By :
                            อัน | 
                         
                    | 
                     | 
                 
                
                     | 
                     | 
                     | 
                 
                | 
             
           
			         | 
             | 
         
        
             | 
            | 
             | 
             | 
         
          
	    
     
               
		
     
		
	  
        
             | 
            | 
            | 
             | 
         
        
             | 
                       | 
          
            
               
                 Code (C#) 
private static SqlConnection GetConnection()
        {
            string strCon = WebConfigurationManager.ConnectionStrings["Connect_Office"].ConnectionString;
            SqlConnection obj_Con = new SqlConnection();
            obj_Con.ConnectionString = strCon;
            return obj_Con;
        }
private static int Getdata()
{
   SqlConnection con =null;
   SqlDataReader reader = null;
   int i =null;
   try
    {
     con = GetConnection();
     string strCommand = "select * from TB_Company" ;
     SqlCommand cmd = new SqlCommand(strCommand, con);
     con.Open();
     reader = cmd.ExecuteReader();
     while(reader.read())
     {
          return i ++;
     }}
catch (Exception exp)
     {
                HttpContext.Current.Trace.Warn("Error in GetCompanyByID()", exp.Message, exp);
            }
            finally
            {
                if (con != null) con.Close();
                if (reader != null) reader.Close();
            }
            return null;
        
}
 
 
ลองทำดูนะครับ เอาไปแบบครบๆ เลย ^^                        
               
               | 
             
            
              
			                                
              
                
                     | 
                     | 
                     | 
                 
                
                     | 
                  
                      
                        | Date :
                            2009-11-10 15:31:53 | 
                        By :
                            ksillapapan | 
                         
                    | 
                     | 
                 
                
                     | 
                     | 
                     | 
                 
                | 
             
           
			         | 
             | 
         
        
             | 
            | 
             | 
             | 
         
          
	    
     
               
		
     
		
	  
        
             | 
            | 
            | 
             | 
         
        
             | 
                       | 
          
            
               
                 Code (ASP & Access) 
<% Option Explicit %>
<html>
<head>
<title>ThaiCreate.Com ASP & Microsoft Access Tutorial</title>
</head>
<body>
<%
Dim Conn,strSQL,objRec
Set Conn = Server.Createobject("ADODB.Connection")
Conn.Open "DRIVER=Microsoft Access Driver (*.mdb);DBQ=" & Server.MapPath("mydatabase.mdb"),"" , ""
strSQL = "SELECT * FROM customer "
Set objRec = Server.CreateObject("ADODB.Recordset")
objRec.Open strSQL, Conn, 1,3
%>
<table width="600" border="1">
  <tr>
    <th width="91"> <div align="center">CustomerID </div></th>
    <th width="98"> <div align="center">Name </div></th>
    <th width="198"> <div align="center">Email </div></th>
    <th width="97"> <div align="center">CountryCode </div></th>
    <th width="59"> <div align="center">Budget </div></th>
    <th width="71"> <div align="center">Used </div></th>
  </tr>
<%
	While Not objRec.EOF
%>
	  <tr>
		<td><div align="center"><%=objRec.Fields("CustomerID").Value%></div></td>
		<td><%=objRec.Fields("Name").Value%></td>
		<td><%=objRec.Fields("Email").Value%></td>
		<td><div align="center"><%=objRec.Fields("CountryCode").Value%></div></td>
		<td align="right"><%=objRec.Fields("Budget").Value%></td>
		<td align="right"><%=objRec.Fields("Used").Value%></td>
	  </tr>
<%
	objRec.MoveNext
	Wend
%>
</table>
<%
	objRec.Close()
	Conn.Close()
	Set objRec = Nothing
	Set Conn = Nothing		
%>
</body>
</html>
                        
               
               | 
             
            
              
			  			  
			                                
              
                
                     | 
                     | 
                     | 
                 
                
                     | 
                  
                      
                        | Date :
                            2009-11-10 21:48:18 | 
                        By :
                            webmaster | 
                         
                    | 
                     | 
                 
                
                     | 
                     | 
                     | 
                 
                | 
             
           
			         | 
             | 
         
        
             | 
            | 
             | 
             | 
         
          
	    
     
      		  
	
     |