i am really very new to asp.net. please help me out here. i want to retrieve data from the sql server. i have a column in the table that contains the same value as the user login name,so when retrieving data i want to use the login name how do i do that?pliz help me.
thanks in advance...
Sandeep Singh ShekhawatRank #147 · 15.6K pointsPosted Oct 29, 2012, 8:40 PM EDT
using System.Data.SqlClient;
2. create a function in that class which retrun sqlConnection
public static SqlConnection Connection() { string connectionString = "Data Source=sandeepss-PC;database=Development;user=sa;password=knowdev"; SqlConnection con = new SqlConnection(); con.ConnectionString = connectionString; return con;3 create a function which return all login names in a data Table
public static DataTable getUserLogin() { DataTable dt = new DataTable(); SqlConnection con = Connection(); SqlCommand cmd = new SqlCommand(); cmd.CommandText = "select userLogin from tbl_login"; cmd.Connection = con; con.Open(); SqlDataReader reader = cmd.ExecuteReader(); dt.Load(reader); return dt; }