using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using MySql.Data.MySqlClient;
using System.Configuration;
namespace CollectDetails.Models
{
public class cPerson
{
public string ideshot_bulk_offers { get; set; }
public string ideshot_bulk_emails { get; set; }
public string accomName { get; set; }
public String tripadvisor { get; set; }
public String travellerReviews { get; set; }
public string resort { get; set; }
public string region { get; set; }
public String rating { get; set; }
public string boardBasis { get; set; }
public string departAirport { get; set; }
public string month { get; set; }
public String duration { get; set; }
public String wasPrice { get; set; }
public String nowPrice { get; set; }
public string optStatement { get; set; }
public string offerText { get; set; }
public string optText { get; set; }
public string fullDescription { get; set; }
public string url { get; set; }
public String ord { get; set; }
//public int PersonID { get; set; }
//public string Name { get; set; }
//public string Address1 { get; set; }
//public string Address2 { get; set; }
//public byte[] Photo { get; set; }
private bool connection_open;
private MySqlConnection connection;
public cPerson()
{
}
public cPerson(int arg_limit)
{
Get_Connection();
// PersonID = arg_i;
// m_Person = new CPersonMaster();
// List<CPersonMaster> PersonList = new List<CPersonMaster>();
//PersonList = CComs_PM.Fetch_PersonMaster(connection, 4, arg_id);
//if (PersonList.Count==0)
// return "";
//m_Person = PersonList[0];
//DB_Connect.CloseTheConnection(connection);
try
{
MySqlCommand cmd = new MySqlCommand();
cmd.Connection = connection;
cmd.CommandText =
string.Format("SELECT t1.* FROM eshot_bulk_offers AS t1 WHERE t1.ideshot_bulk_emails IN (SELECT ideshot_bulk_emails FROM eshot_bulk_emails WHERE send_status = 'PROCESSED' AND basedOn = 0 ORDER BY ideshot_bulk_emails DESC) ORDER BY t1.ideshot_bulk_emails DESC, t1.ord LIMIT 2");
MySqlDataReader reader = cmd.ExecuteReader();
try
{
reader.Read();
if (reader.IsDBNull(0) == false)
ideshot_bulk_offers = reader.GetString(0);
else
ideshot_bulk_offers = null;
if (reader.IsDBNull(1) == false)
ideshot_bulk_emails = reader.GetString(1);
else
ideshot_bulk_emails = null;
if (reader.IsDBNull(2) == false)
accomName = reader.GetString(2);
else
accomName = null;
if (reader.IsDBNull(3) == false)
tripadvisor = reader.GetString(3);
else
tripadvisor = null;
if (reader.IsDBNull(4) == false)
travellerReviews = reader.GetString(4);
else
travellerReviews = null;
if (reader.IsDBNull(5) == false)
resort = reader.GetString(5);
else
resort = null;
if (reader.IsDBNull(6) == false)
region = reader.GetString(6);
else
region = null;
if (reader.IsDBNull(7) == false)
rating = reader.GetString(7);
else
rating = null;
if (reader.IsDBNull(8) == false)
boardBasis = reader.GetString(8);
else
boardBasis = null;
if (reader.IsDBNull(9) == false)
departAirport = reader.GetString(9);
else
departAirport = null;
if (reader.IsDBNull(10) == false)
month = reader.GetString(10);
else
month = null;
if (reader.IsDBNull(11) == false)
duration = reader.GetString(11);
else
duration = null;
if (reader.IsDBNull(12) == false)
wasPrice = reader.GetString(12);
else
wasPrice = null;
if (reader.IsDBNull(13) == false)
nowPrice = reader.GetString(13);
else
nowPrice = null;
if (reader.IsDBNull(14) == false)
optStatement = reader.GetString(14);
else
optStatement = null;
if (reader.IsDBNull(15) == false)
offerText = reader.GetString(15);
else
offerText = null;
if (reader.IsDBNull(16) == false)
optText = reader.GetString(16);
else
optText = null;
if (reader.IsDBNull(17) == false)
fullDescription = reader.GetString(17);
else
fullDescription = null;
if (reader.IsDBNull(18) == false)
url = reader.GetString(18);
else
url = null;
if (reader.IsDBNull(19) == false)
ord = reader.GetString(19 );
else
ord = null;
reader.Close();
}
catch
{
}
}
catch { }
connection.Close();
}
private void Get_Connection()
{
connection_open = false;
connection = new MySqlConnection();
//connection = DB_Connect.Make_Connnection(ConfigurationManager.ConnectionStrings["SQLConnection"].ConnectionString);
connection.ConnectionString = ConfigurationManager.ConnectionStrings["MySQLConnection"].ConnectionString;
// if (db_manage_connnection.DB_Connect.OpenTheConnection(connection))
if (Open_Local_Connection())
{
connection_open = true;
}
else
{
// MessageBox::Show("No database connection connection made...\n Exiting now", "Database Connection Error");
// Application::Exit();
}
}
private bool Open_Local_Connection()
{
try
{
connection.Open();
return true;
}
catch (Exception)
{
return false;
}
}
}
}
目前它正在从检索到的数据库表中保存一行。请解释如何通过阅读器检索数据库表中的所有行。