Pages

Showing posts with label programming. Show all posts
Showing posts with label programming. Show all posts

Wednesday, September 4, 2013

Access Database - Python

Contoh: import MySQLdb

# Open database connection
db = MySQLdb.connect("localhost","user","pass","db_name" )

# prepare a cursor object using cursor() method
cursor = db.cursor()

# Prepare SQL query to INSERT a record into the database.
sql = "SELECT * FROM person"

try:
    # Execute the SQL command
    cursor.execute(sql)
    # Fetch all the rows in a list of lists.
    results = cursor.fetchall()
    for row in results:
        p_alias = row[1]
        p_image = row[3]
        # Now print fetched result
        print "p_alias=%s,p_image=%s" % \
              (p_alias, p_image)
except:
    print "Error: unable to fecth data"

# disconnect from server
db.close()

Tuesday, July 16, 2013

Sintaks PHP/HTML Untuk Menampilkan Waktu SIstem (SYSDATE)

<html>
<body>
  
	echo "Current date and time :
";  
	$result = mysql_query("SELECT SYSDATE()");  
	while($row=mysql_fetch_array($result))  
	{  
		echo $row["SYSDATE()"];  
	}
?>
</body>
<html>

Thursday, December 6, 2012

Membaca file XML menggunakan Visual C#

. . . dengan membentuk class XmlTextReader.
Further info, go to http://support.microsoft.com/kb/307548#4 :)


Step-step ringkasnya:
  1. Bikin New Project di Visual Studio (yang saya mah yang 2008) - Pilih Consule Application C#. Nama filenya terserah, apa aja.
  2. Tambahkan System.Xml sebagai library pada class program.cs (class bawaan project) nya. Ini adalah direktif sebelum mendeklarasikan yang lain.
    System.Xml
  3. Buat object baru dengan nama reader bertipe XmlTextReader dengan paramenter file xml yang ingin dibaca. (Example: books.xml)
    XmlTextReader reader = new XmlTextReader ("books.xml");
  4. Buka file books 

#noted
Thanks to Ka Dioo for reference! haha