I am a novice C# programmer and need to learn where and how to store the data access code in a central place in a windows applications, developed using Visual Studio 2012.
I know that in ASP.Net I use the configuration file to place and access reference to the code. But how does this apply to a C# Windows application?
What I have been doing for a long time is to write almost the same code or almost the same code for data access over and over:
Something like the method below with little variations (it could be "void" instead of data type):
public DataTable GetMyData()
con = new SqlConnection("Server=myServer;;Database=myDatabase;integrated security=True");
SqlCommand comm = new SqlCommand("Select id,Name from myTable order by LastName", con);
SqlDataAdapter dataAdapter1 = new SqlDataAdapter(comm);
DataSet ds1 = new DataSet();
Please give example if possible.