Thursday, September 11, 2008

Issuing SQL Commands

Problem

Now that you've established a connection to a database through a provider, you're ready to issue SQL commands. But how?

Solution
Use a Command object to issue SQL commands directly to your database through the provider connection.

Discussion
The following code updates a SQL Server table named Table1, changing every Column2 field to 25 whenever Column1 has a value of 0:

' ----- Connect to the database.
Dim connectionString As String = _
"Data Source=MySystem\SQLEXPRESS;" & _
"Initial Catalog=MyDatabase;Integrated Security=true"
Dim theDatabase As New SqlClient.SqlConnection(connectionString)
theDatabase.Open()

' ----- Prepare the SQL statement for use.
Dim sqlStatement As New SqlClient.SqlCommand( _
"UPDATE Table1 SET Column2 = 25 WHERE Column1 = 0", _
theDatabase)
sqlStatement.ExecuteNonQuery()

' ----- Clean up.
theDatabase.Close()
theDatabase.Dispose()


Connecting to a Data Provider

Problem
You are writing an application that interacts with a database, and you need to connect to it to run some queries.

Solution
Use a Connection object and a "connection string" to establish the connection you will use for queries and updates.

Discussion
The following set of statements establishes a connection to a SQL Server Express database named MyDatabase running on the system named MySystem, using the active Microsoft Windows login account for its security access:

Dim theDatabase As System.Data.SqlClient.SqlConnection
Dim connectionString As String = _
"Data Source=MySystem\SQLEXPRESS;" & _
"Initial Catalog=MyDatabase;Integrated Security=true"

theDatabase = New SqlClient.SqlConnection(connectionString)
theDatabase.Open( )
' ---- Perform database processing here, then…
theDatabase.Close( )
theDatabase.Dispose( )


Thursday, September 4, 2008

andLinux, run Linux applications in Windows

For those who like to run Linux applications but still use a PC that had Windows OS, now do not need to go back and forth reboot to run a dual boot or run a virtualization program such a Virtual PC or Virtual Box. With andLinux now we can run linux applications in windows as if the applications are Windows applications.
andLinux uses the Ubuntu Linux distribution that runs in a seamless environment in Windows 2000 (2000, XP, 2003, Vista, 32-bit version only). and Linux using coLinux as corenya. coLinux kernel is ported into Windows.This technology is mentioned more than a virtual machine because Windows and coLinux kernel merge and do not emulate a PC, making it more efficient.