Introduction to SQL
The Structured Query Language, known as SQL, is a universal language used on various computer systems to create and manage databases.
ASP.NET Databases With Microsoft Access: Introduction to SQL
Introduction to SQL#
The Structured Query Language#
Introduction#
SQL, or Structured Query Language, is a common language that runs across many computer systems for building and managing databases.
The SQL Interpreter#
As a programming language, SQL sends instructions to an internal interpreter program, so your commands must be exact. SQL is not case-sensitive. When you build a web site, you can write the required code and then supply it to an OleDbCommand object that you created. For example:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.OleDb;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
using (OleDbConnection connection =
new OleDbConnection("Provider=Microsoft.Jet.OLE.4.0;" +
"Data Source=" + Server.MapPath("App_Data/exercise.mdb")))
{
OleDbCommand CommandToExecute = new OleDbCommand(SQL Code, connection);
}
}
}In this example, the SQL Code factor represents a SQL statement you would write and pass it as a string.
Executing a Statement#
After passing the SQL code to a command, to execute it, you can call the ExecuteNonQuery() method of your OleDbCommand object. This would be done as follows:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.OleDb;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
using (OleDbConnection connection =
new OleDbConnection("Provider=Microsoft.Jet.OLE.4.0;" +
"Data Source=" + Server.MapPath("App_Data/exercise.mdb")))
{
OleDbCommand command = new OleDbCommand(SQL Code, connection);
connection.Open();
command.ExecuteNonQuery();
}
}
}Previous Copyright © 2009 C# Key Next

