如何將兩個列值添加到列表中,兩列列在不同的表中。電子郵件位於tbl_user表中,組名位於tbl_group表中。我想爲自動完成文本框的電子郵件和組名使用前綴文本。現在與查詢我能夠將電子郵件ID添加到列表中,當我輸入的常用3則電子郵件ID開始ARR顯示我怎麼能做到這一點兩個組名和EMAILID如何將兩個列值添加到列表
public static string[] GetCompletionList(string prefixText, int count, string contextKey)
{
MySqlCommand command = new MySqlCommand();
string textforlist = "SELECT tbl_user.Email from tbl_user WHERE tbl_user.OrganisationID = '1' AND UserActive='Yes'AND tbl_User.Email like '" + prefixText + "%'";
DataSet ds = new DataSet();
MySqlParameter[] param = new MySqlParameter[1];
param[0] = new MySqlParameter("@OrganisationID", MySqlDbType.Int32);
param[0].Value = count;
command.Parameters.AddWithValue("@OrganisationID", count);
using (DataServer server = new DataServer())
{
ds = server.ExecuteQuery(CommandType.Text, textforlist, param);
}
string textforlist1 = "SELECT tbl_group.GroupName from tbl_group WHERE tbl_group.OrganisationID = '1' AND GroupActive='Yes'AND tbl_group.GroupName like '" + prefixText + "%'";
DataSet ds1 = new DataSet();
using (DataServer server = new DataServer())
{
ds1 = server.ExecuteQuery(CommandType.Text, textforlist1, param);
}
List<string> cityList = new List<string>();
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
{
cityList.Add(ds.Tables[0].Rows[i][0].ToString());
cityList.Add(ds1.Tables[0].Rows[i][0].ToString());
}
return cityList.ToArray();
}
如何確保它返回數組,即使1值爲空 – Mark
只需使用兩個'for'循環 – BrokenGlass
我想添加int newOrgID = Convert.ToInt32(Session [「uOrgID」]。ToString());獲取此值並將此值添加到@OrganisationID的參數值 – Mark