using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Web.Configuration;
using System.Configuration;

public class MyClass
{
    public static DataTable GetCustomers()
    {
        string connectionString = WebConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
        SqlConnection conn = new SqlConnection(connectionString);
        SqlCommand comm = new SqlCommand("SELECT TOP 10 [CustomerID], [CompanyName], [ContactName] FROM [Customers]", conn);
        SqlDataAdapter adapter = new SqlDataAdapter(comm);
        DataTable table = new DataTable();
        conn.Open();
        try
        {
            adapter.Fill(table);
        }
        finally
        {
            conn.Close();
        }
        return table;
    }
    public static void Edit(string CustomerID, string CompanyName, string ContactName)
    {
        SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString);
        SqlCommand command = new SqlCommand("UPDATE [Customers] SET [CompanyName] = @CompanyName, [ContactName] = @ContactName WHERE [CustomerID] = @CustomerID", conn);
        command.Parameters.Add(new SqlParameter("@CompanyName", CompanyName));
        command.Parameters.Add(new SqlParameter("@ContactName", ContactName));
        command.Parameters.Add(new SqlParameter("@CustomerID", CustomerID));
        conn.Open();
        try
        {
            command.ExecuteNonQuery();
        }
        finally
        {
            conn.Close();
        }
    }
}
