Showing posts with label Tutorial. Show all posts
Showing posts with label Tutorial. Show all posts

Tutorial: Visual Basic 6.0



http://www.vb6.us/:
Getting to know the VB6 IDE
Visual Basic & ADO Tutorial
Using ADO and stored procedures

Tutorial: C#

http://www.dotnetspider.com/tutorials/DotNet-Tutorial-271.aspx

ADO.NET


ADO.NET is the data access model that comes with the .NET Framework. ADO.NET provides the classes required to communicate with any database source (including Oracle, Sybase, Microsoft Access, Xml, and even text files).

DataAccess Providers in .NET


ADO.NET comes with few providers, including:
  • OleDb
  • SqlClient

    There are other providers available, but we are not including them here as this tutorial is meant for beginners! When you want them, search for ADO.NET providers in Google or MSDN

    Microsoft made the SQL Server. So they gave a separate provider, specifically made for SQL Server. We can use the OleDb provider for all other database sources including MS Access, Oracle, Sybase etc. There is a separate provider available for Oracle.

    A DATA PROVIDER is a set of classes that can be used to access, retrieve and manipulate data from the databases.

    Both OleDb and SqlClient has its own set of classes, but they have the same concepts. We would like to classify the classes into two broad categories (this is not a microsoft classification, anyway!)

  • Classes for communicate with database
  • Classes for holding/manipulating data

    The job of first category of classes is to communicate with database and send or retrieve data from the database. The second category of the classes will be used as a carrier of data.

    Classes for communicating with database


    The Connection, Command, DataReader, and DataAdapter
    objects are the core elements of the ADO.NET provider model.

    Each provider may have classes equivalent to above objects. The name of the classes vary slightly to represent the provider type appropriately.

    Depending on the type of database you work on, you will have to choose either OleDb or SqlClient (or, some other provider) objects. Since all our samples use MS Access database, we will be using OleDb objects in all the samples. If you like to use SqlServer, you just need to replace the OleDb objects with the equivalent SqlClient objects.

    Classes for holding data

    The following are the main classes used to hold data in Ado.NET:

  • DataSet
  • DataTable
  • DataRow

  • A DataSet is an in-memory representation of the database.
  • DataSet contains DataTables (and more...)
  • DataTable represents a database table
  • DataTable contains DataRows (and more...)
  • A DataRow represents a record in a database table.
  • DataRow is a collection of all fields in a record.

    We can use the DataAdapter or DataReader to populate data in DataSet. Once we populate data from database, we can loop through all Tables in the DataSet and through each record in each Table.

    On the first look, this may look bit confusing, but once you understand the concept and get familiar with the Ado.NET classes, you will appreciate the power and flexibility of Ado.NET.


    http://www.dotnetspider.com/tutorials/DotNet-Tutorial-281.aspx
  • Tutorial: JavaScript:Defining Array

    Array in JavaScript is class derived from Object. There are several ways of defining an array:

    1. Regular array. Pass an optional integer argument to control array's size. However, if it is defined, no more element can be defined exceeding this number.
    ; var myfriends = new Array(optionalElementNumber)
    ; myfriends[0] = "John"
    ; myfriends[1] = "Bob"
    ; myfriends[2] = "Sue"

    2. Condensed array:
    ; var myfriends = new Array("John", "Bob", "Sue")

    3. Literal array:
    ; var myfriends = ["John", "Bob", "Sue"]

    4. Empty array:
    ; var myArray = []
    ; myArray.push("John")
    ; myArray.push("Bob")
    ; myArray.push("Sue")

    The elements/values of an array can be numeric, string, another array and object, or reference points to these:
    ; var var_0 = "John"
    ; var var_1 = "Bob"
    ; var var_2 = "Sue"
    ; var myfriends = new Array(var_0, var_1, var_2)
    or
    ; var myfriends = [var_0, var_1, var_2]

    When an element is another array, it becomes multidimensional array.

    Tutorial: JSON Format

    The beauty of JSON is it can stringify a multidimensional array, either indexed or associative array, into a linear string, so it can be passed between functions as well as languages. The basic rule is as follows:

    1. If value is numeric, do not include the quote. If the value is string, include the double quote. For instance: 1, 3, "ab", "5". It is not necessary to use quote for the key in associative array if no whitespace used in key, else, use double quote. However, double quote on keys is required by JSON format specification.

    2. Use ":" to separate key and value if the element is of associative relationship. For instance: Category_2:3.

    3, use comma to separate elements. For instance: 1, Category_2:3, "ab".

    4. Use [] to signify a single dimensional indexed array. For instance [1, 3, "ab"]. When calling an element within a single indexed dimensional array, just like usual: arr[2]. In this case, it would return 3.

    5. Use {} to signify a single dimensional associative array. For instance {Category_2:3}. For multi-elements associative array, one bracket is enough: {Category_2:3, Category_3:"ab"}. When calling an element within a single associative dimensional array, use following format: arr.Category_3. In this case, it would return "ab".

    Here is an example:

    {lastName: "Smith",
    age: 25,
    address:
    {streetAddress: "21 2nd Street",
    postalCode: "10021"
    },
    phoneNumber:
    [{ type: "home",
    },
    { type: "fax",
    number: "646 555-4567"
    }
    ]
    }

    To get fax number here, call: arr.phoneNumber[1].number

    Another example starts with index array:

    [
    {A:a}
    ,{B:b}
    ]

    How to stringify JSON for multidimensional array? DON't use JavaScript built-in function stringify(). It does not work for multidimensional array. Use ''+arr to make it string.


    http://en.wikipedia.org/wiki/Json

    Labels