public static void Connect() { string connectStr = "server=168.33.162.63;port=3306;user=root;password=fairhr0755SZ; database=HealthCheck;"; string sql = "select * from orders where id = '1997'"; MySqlConnection conn = new MySqlConnection(connectStr); try { conn.Open(); MySqlCommand cmd = new MySqlCommand(sql, conn); MySqlDataReader reader = cmd.ExecuteReader(); while (reader.Read()) { string name = reader.GetString("PeopleName"); string s = reader.GetEnumerator().ToString(); Console.WriteLine(name + s); } } catch (MySqlException ex) { Console.WriteLine(ex); } finally { conn.Close(); } }
public static EmpModel GetEmployee(int?id) { EmpModel model = new EmpModel(); using (MySqlConnection con = new MySqlConnection(conString)) { con.Open(); using (MySqlCommand cmd = new MySqlCommand()) { cmd.Connection = con; cmd.CommandType = CommandType.Text; cmd.CommandText = "Select * from employee where EmpId = " + id + ""; MySqlDataReader rdr = cmd.ExecuteReader(); model = (EmpModel)rdr.GetEnumerator().Current; } con.Close(); } return(model); }
public override IEnumerator GetEnumerator() { return(reader.GetEnumerator()); }
public IEnumerator GetEnumerator() { return(_mySqlDataReader.GetEnumerator()); }
public IEnumerator GetEnumerator() => _dataReader.GetEnumerator();