Understanding What is SQL Server And Examples


SQL Server is a relational database management system (RDBMS) designed for applications with client / server architectures. The terms client, server, and client / server can be used to refer to very general or specific concepts of hardware or software. At a very general level, a client is any component of a system that requests services or resources from other system components. While a server is every component of the system that provides services or resources to other system components.

Here is a sample SQL Server that runs in MS Excel which I managed to make you can too

1. First of all make the database .. The database assumption has been made with the database name “dbtest”, the name of the table “mhs”. Here is an illustrated data that has been created.

2. Create an Excel add-in project. The steps are as follows:

-Open Visual Studio 2008
-Choose File -> New -> Project
-In the Product Types box, select Visual C #, then select Office, then select 2007
-In the Tamplate box, select Excel 2007 Add-in
-In the name box, type ExcelAddIn1
-Click Ok

3. In ThisAddIn class add the following code:

private void ThisAddIn_Startup(object sender, System.EventArgs e)
SqlDataReader reader = null;
string myConnectionString = “Data Source=.\\SQLEXPRESS;Initial Catalog=dbtest;Integrated Security=True;”;
SqlConnection myConnection = new SqlConnection(myConnectionString);
string myInsertQuery = “SELECT npm,nama FROM mhs”;
SqlCommand myCommand = new SqlCommand(myInsertQuery);
myCommand.Connection = myConnection;
reader = myCommand.ExecuteReader();
Excel.Worksheet activeWorksheet = ((Excel.Worksheet)Application.ActiveSheet);
Excel.Range cellB1 = activeWorksheet.get_Range(“B1”, missing);
cellB1.Value2 = “NPM”;
cellB1.EntireColumn.ColumnWidth = 10;
Excel.Range cellC1 = activeWorksheet.get_Range(“C1”, missing);
cellC1.Value2 = “Nama”;
//Mencetak isi table mhs ke excel dari cell B2
int counter = 2; //Set awal baris
while (reader.Read())
cellB1.get_Offset(1, 0).Value2 = (String)reader[0];
cellC1.get_Offset(1, 0).Value2 = (String)reader[1];

4. Add using System.Data.SqlClient;

5. Run the program by pressing the F5 key

Here’s the result




This site uses Akismet to reduce spam. Learn how your comment data is processed.