Zoo tutorials:
[
SQL
|
Linux
|
XML
]
ProgZoo:
[
Java
|
C#
|
VB
|
C++
|
Perl
]
Log in
WebCT ID:
Password:
Napier students only
A Gentle Introduction to
Java Programming
Define a Class
Top Ten Programs
Hello World
Count 0 to 9
Read a Text File
Sum an Array
Convert a String to a Number
Use a Hash Table
Regular Expression
Read From a Database
Read XML
Define a Class
C#
Java
1. [ C# ] Read a single value
using System; using System.Data.SqlClient; namespace SQLHacks{ class Sample{ public static void Main(string[] args){ try{ SqlCommand comm = new SqlCommand(); comm.Connection = new SqlConnection( "Data Source=ME1C049-006103\\zoo;" +"Initial Catalog=gisq;" +"user=scott;password=tiger;"); comm.CommandText = "SELECT population FROM bbc WHERE name='France'"; comm.Connection.Open(); SqlDataReader cursor = comm.ExecuteReader(); while (cursor.Read()) Console.WriteLine(cursor["population"]); comm.Connection.Close(); }catch (Exception e){ Console.WriteLine(e.ToString()); } } } }
Big
test text
1. [ Java ] Read a single value
class Country{ //These are the public attribute public String name; public long population; //This is a constructor Country(String n,long p){ name = n; population = p; } //This is a method public String toString(){ return name + " (" + population + ")"; } } public class Demo{ public static void main(String[] args){ Country fr = new Country("France",66000000L); System.out.println(fr.toString()); } }
Big
test text