Sql data adapter in C#  

Posted by: Quadtechindia in

using System.Data;
using System.Data.SqlClient;
using System.Windows.Forms;

namespace WindowsFormsApplication9
public partial class Form1 : Form
public Form1()

void FillData()
// 1
// Open connection
using (SqlConnection c = new SqlConnection(
// 2
// Create new DataAdapter
using (SqlDataAdapter a = new SqlDataAdapter("SELECT * FROM EmployeeIDs", c))
// 3
// Use DataAdapter to fill DataTable
DataTable t = new DataTable();

// 4
// Render data onto the screen
dataGridView1.DataSource = t; // <-- From your designer

Part 1. This creates a new SqlConnection instance. Note that you must include the System.Data.SqlClient namespace in your program. [See top of code]

Part 2. After calling Open() on the SqlConnection, we use another using block for the SqlDataAdapters. The using statements are ideal for disposing of resources, making your programs more efficient and reliable. [C# SqlClient Tutorial - dotnetperls.com]

Part 3. Here we instantiate and Fill a new DataTable. Note that the Fill method on DataTable will populate the internal rows and columns of the DataTable to match the SQL result.

Part 4. This part is commented out because it won't compile unless you have a DataGridView. We see the DataSource being assigned to the DataTable. The result will be a filled DataGridView with data from SQL Server.

Culture and UI Culture for ASP.NET Web Page Globalization  

Posted by: Quadtechindia in

In an ASP.NET Web page, you can set to two culture values, the Culture and UICulture properties. The Culture value determines the results of culture-dependent functions, such as the date, number, and currency formatting, and so on. The UICulture value determines which resources are loaded for the page.
The two culture settings do not have to have the same value. Depending on your application, it might be important to set them separately. An example is a Web auction site. The UICulture property might change for each Web browser, whereas the Culture stays constant. Therefore, prices are always displayed in the same currency and formatting.

<%@ Page Language="C#" uiculture="auto" %>
<%@ Import Namespace="System.Threading" %>
<%@ Import Namespace="System.Globalization" %>
script runat="server"
protected override void InitializeCulture()
if (Request.Form["ListBox1"] != null)
String selectedLanguage = Request.Form["ListBox1"];
UICulture = selectedLanguage ;
Culture = selectedLanguage ;

Thread.CurrentThread.CurrentCulture =
Thread.CurrentThread.CurrentUICulture = new
form id="form1" runat="server"
asp:ListBox ID="ListBox1" runat="server"
asp:ListItem Value="en-US"
Selected="True"English /asp:ListItem
asp:ListItem Value="es-MX">EspaƱol /asp:ListItem
asp:ListItem Value="de-DE">Deutsch /asp:ListItem
br /
asp:Button ID="Button1" runat="server"
Text="Set Language"
meta:resourcekey="Button1" /
br /
asp:Label ID="Label1" runat="server"
meta:resourcekey="Label1" /

tags cannot be posted so please add angels brackets