hadoop hadoop

hadoop hadoop

  • NA
  • 159
  • 50.8k

generate LINQ module from this C# module for data set

May 29 2015 2:25 AM
I am trying to change the below code as LINQ. But I am unable to do this, please guide me. 
 
private void getData(AutoCompleteStringCollection dataCollection)
{
string connetionString = null;
SqlConnection connection ;
SqlCommand command ;
SqlDataAdapter adapter = new SqlDataAdapter();
DataSet ds = new DataSet();
connetionString = "Data Source=.;Initial Catalog=pubs;User ID=sa;password=zen412";
string sql = "SELECT DISTINCT [fname] FROM [employee]";
connection = new SqlConnection(connetionString);
try
{
connection.Open();
command = new SqlCommand(sql, connection);
adapter.SelectCommand = command;
adapter.Fill(ds);
adapter.Dispose();
command.Dispose();
connection.Close();
foreach (DataRow row in ds.Tables[0].Rows)
{
dataCollection.Add(row[0].ToString());
}
}
catch (Exception ex)
{
MessageBox.Show("Can not open connection ! ");
}
}
I want to get the user_name from my AppUser table. How can I do this?

Answers (1)