how to retrieve data from a sql server database in c 23

Solutions on MaxInterview for how to retrieve data from a sql server database in c 23 by the best coders in the world

showing results for - "how to retrieve data from a sql server database in c 23"
Ariana
04 Mar 2020
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        }
queries leading to this page
c 23 code to retrieve data from sql databasehow to get retrieve data from a database and display it c 23get data from database c 23fastest way to retrieve data from sql server in c 23c 23 how to retrieve data from a table sqlhow to get data from database in c 23how to retrieve data from the database in c 23ways to get data from database c 23how to retrieve data from mysql database in c 23sql get data c 23how to get data from sql server in c 23how to retrieve data from the database in c 23 fromhow to get sql data in c 23retrieve data from database c 23retrieve data from sql server in c 23how to read data from sql server in c 23get sql data in c 23get data from sql server in c 23get data from sql server c 23get the data from database in c 23how to retrieve data from sql server database in c 23 console applicationc 23 get data from databasec 23 get data from sql server tablehow to read data from sql database in c 23how to retrieve data from database in c 23get data from sql server db c 23retrieve data from database in c 23get data from db c 23get data from database in c 23ways to retrieve data from database in c 23 how to retrieve data from an sql table and output it c 23sql query to retrieve data from database in c 23how to retrieve data from sql server in asp net using c 23read data from sql database in c 23how to get data from sql to c 23get data from sql database c 23 how to retrieve data from database in asp net using c 23c 23 retrieve data from databasehow to retrieve data from a sql server database in c 23how to retrieve data from sql server in c 23 to data tab 3ble how to retrieve data from sql server database in c 23 console application with data tableretrieve data from database in c 23 asp netget data from db in c 23how to retrieve data from a sql server database in c 23