Skip to main content

Posts

ADO.NEt - the Concept

The DataSet type is a container for any number of DataTable objects, each of which contains a collection of DataRow and DataColumn objects. Data adapters are used to push and pull DataSets to and from a given data store. The data adapter object of your data provider handles the database connection automatically. In aneffort to increase scalability, data adapters keep the connection open for the shortest amount of time possible. Once the caller receives the DataSet object, the calling tier is completely disconnected from the database and left with a local copy of the remote data. The caller is free to insert, delete, or update rows from a given DataTable, but the physical database is not updated until the caller explicitly passes the DataSet to the data adapter for updating. In a nutshell, DataSets allow the clients to pretend they are always connected; however, they actually operate on an in-memory database.

VB.net learning: Building a Reusable Data Access Library

Namespace AutoLotConnectedLayer Public Class InventoryDAL ' This member will be used by all methods. Private sqlCn As SqlConnection = Nothing Public Sub OpenConnection(ByVal connectionString As String) sqlCn = New SqlConnection() sqlCn.ConnectionString = connectionString sqlCn.Open() End Sub Public Sub CloseConnection() sqlCn.Close() End Sub `Adding the Insertion Logic Public Sub InsertAuto(ByVal id As Integer, ByVal color As String, ByVal make As String, ByVal petName As String) ' Format and execute SQL statement. Dim sql As String = String.Format("Insert Into Inventory " & "(CarID, Make, Color, PetName) " & "Values'{0}', '{1}', '{2}', '{3}')", id, make, color, petName) ' Execute using our connection. Using cmd As New SqlCommand(sql, Me.sqlCn) cmd.ExecuteNonQuery() End Using End Sub ... End Class End Namespace

VB.net learning: A Complete Data Provider Factory Example

Step 1: insert an App.config file to the current project and define an empty <appSettings> element. Add a new key-named provider that maps to the namespace name of the data provider you wish to obtain (System.Data.SqlClient). Also, define a connection string that represents a connection to the xx database. <?xml version="1.0" encoding="utf-8" ?> <configuration> <appSettings> <!-- Which provider? --> <add key="provider" value="System.Data.SqlClient" /> <!-- Which connection string? --> <add key="cnStr" value= "Data Source=(local)\SQLEXPRESS; Initial Catalog=AutoLot;Integrated Security=True"/> </appSettings> ... </configuration> Step 2: Read the property file Sub Main() Console.WriteLine("***** Fun with Data Provider Factories *****" & vbLf) ' Get Connection string/provider from *.config. Dim dp As String = ConfigurationManager...

VB.net Learning: Projects with Multiple Modules

Module MyModule Public Sub GreetUser() Console.WriteLine("Hello user...") End Sub End Module Sub Main() ' Show banner. DisplayBanner() ' Call the GreetUser() method in MyModule. MyModule.GreetUser() End Sub Another trait of the module type is that it cannot be directly created using the VB 2010 New keyword (any attempt to do so will result in a compiler error). Therefore, the following code is illegal: ' Nope! Error, can't allocate modules! Dim m as New Module1() Rather, a module simply exposes shared members

VB.net Learning: Enumeration Types

Enumerations are a handy programming construct that allow you to group name/value pairs. For example, assume you are creating a video game application that allows the player to select one of the three character categories(Wizard, Fight , or Thief). Rather than keeping track of simple numerical values to represent each possibility, you could build a custom enumeration using the Enum keyword. ' A VB enumeration type. Enum CharacterType Wizard = 100 Fighter = 200 Thief = 300 End Enum

VB.net Learning: Structure Types

Typically, structures are best suited for modeling geometric and mathematical data and are created in VB using the Structure keyword. ' A VB structure type. Structure Point ' Structures can contain fields. Public xPos As Integer, yPos As Integer ' Structures can contain parameterized constructors. Public Sub New(x As Integer, y As Integer) xPos = x yPos = y End Sub ' Structures may define methods. Public Sub PrintPosition() Console.WriteLine("({0}, {1})", xPos, yPos) End Sub End Structure

VB.net Learning: CTS (Commond Type System)

CTS: Common Type  System , In order that two language communicate smoothly CLR has CTS  Example : In VB you have "Integer" and in C++ you have "long" these datatypes are not compatible so the interfacing between them is very complicated. In order to able that two different languages can communicate Microsoft introduced Common Type System. So "Integer" datatype in VB6 and "int" datatype in C++ will convert it to System.int32 which is datatype of CTS. CLS which is covered in the coming question is subset of CTS.