1 public Person SomeMethod(string fName)
2 {
3 var con = ConfigurationManager.ConnectionStrings["Yourconnection"].ToString();
4
5 Person matchingPerson = new Person();
6 using (SqlConnection myConnection = new SqlConnection(con))
7 {
8 string oString = "Select * from Employees where FirstName=@fName";
9 SqlCommand oCmd = new SqlCommand(oString, myConnection);
10 oCmd.Parameters.AddWithValue("@Fname", fName);
11 myConnection.Open();
12 using (SqlDataReader oReader = oCmd.ExecuteReader())
13 {
14 while (oReader.Read())
15 {
16 matchingPerson.firstName = oReader["FirstName"].ToString();
17 matchingPerson.lastName = oReader["LastName"].ToString();
18 }
19
20 myConnection.Close();
21 }
22 }
23 return matchingPerson;
24 }