Nov 27, 2013

C# Load To DataGridView From SQL Server

using System;                  
using System.Data;
using System.Data.SqlClient;
//Use all These Libararies If Your Connecting SqlServer

//Write These Codes In A Button Click Event Or A Function Or What Ever Event You Want To
#region Codes
string ConnectionString = @"Server=localhost;Database=dbName;Trusted_Connection=True";

SqlConnection connection = new SqlConnection(ConnectionString);

connection.Open();

DataTable dt = new DataTable();  // create a virtual table
SqlDataAdapter sda = new SqlDataAdapter("SELECT * FROM TestTable , connection);
// create a data apadter. i have used sql..

sda.Fill(dt);//load the result from Data Adapter to the Virtual Table

datagridname.DataSource = dt; //add the virtual table to the datagrid.

connection.Close();

#endregion

No comments:

JWT Token Decode Using Jquery

When it come to authentication we use many mechanism. Ones the user authenticated we must keep these details somewhere safe. So we can share...