static void Main(string[] args) { conn = new MySQLConnection(new MySQLConnectionString("10.125.103.139", "heartlink", "qwe", "123").AsString); cmd = new MySQLCommand(); da = new MySQLDataAdapter(); String pass = "******"; String sql = "select ID from students where password="******"ID = {0}", DBReader.GetString(0)); } } finally { DBReader.Close(); conn.Close(); } }
/// <summary> /// Gets the volunteer timestamps to an array.@deprecated Use getLastActiveTimestamp. unstable!! /// </summary> /// <param name="VolunteerID"></param> /// <param name="ACTIVE_ONLY"></param> /// <param name="ONLY_TODAY"></param> /// <returns>A 2 dimension array of timestamps or an empty array</returns> public object [][] getVolunteerTimestamps(uint VolunteerID,Boolean ACTIVE_ONLY=false,Boolean ONLY_TODAY=true){ //Build Query string qry="SELECT * FROM Checkin WHERE VolunteerID="+VolunteerID; if(ACTIVE_ONLY==true) qry+=" AND Active=1"; if(ONLY_TODAY==true) qry+=" AND DATE(TimeIn)=DATE(NOW())"; qry+=" ORDER BY CheckID DESC;"; //Query Data MySQLCommand mc = new MySQLCommand(qry, vlcon); MySQLDataReader dr = mc.ExecuteReaderEx(); List<object>[] rval = { new List<object>(), new List<object>(), new List<object>(), new List<object>()};//data string list int cnt=0; try{ while (dr.Read()) { for (byte curfield = 0; curfield < rval.Length; curfield++) { rval[curfield].Insert(cnt, dr.GetString(curfield)); Console.WriteLine(rval.GetValue(curfield).ToString()); } cnt++; } }finally{ dr.Close(); mc.Dispose(); } return new object[][]{rval[0].ToArray(),rval[1].ToArray(),rval[2].ToArray(),rval[3].ToArray()}; }
public void SelectBlob(MySQLConnection con) { try { con.Open(); MySQLCommand cmd = new MySQLCommand("select col1, col2 from `trntipos` where col1=3", con); //, `SerialNumberLastUsed` cmd.UsePreparedStatement = true; cmd.ServerCursor = true; cmd.Prepare(); MySQLDataReader reader = (MySQLDataReader)cmd.ExecuteReader(); while (reader.Read()) { getBLOBFile("output.jpg", reader, 1); } reader.Close(); cmd.Dispose(); con.Close(); } catch (Exception e) { if (con != null) { con.Close(); } throw e; } }
//显示数据按钮 private void button4_Click_1(object sender, EventArgs e) { MySQLConnection myconn = null; myconn = new MySQLConnection(new MySQLConnectionString("localhost", "water", "root", "root", 3306).AsString); try { myconn.Open(); //打开连接 MySQLCommand cmd = new MySQLCommand("select * from waterinfor", myconn); //cmd.ExecuteNonQuery(); MySQLDataReader sdr = cmd.ExecuteReaderEx(); while (sdr.Read()) { //构建一个ListView的数据,存入数据库数据,以便添加到listView1的行数据中 ListViewItem lt = new ListViewItem(); //将数据库数据转变成ListView类型的一行数据 lt.Text = sdr["id"].ToString(); lt.SubItems.Add(sdr["time"].ToString()); lt.SubItems.Add(sdr["place"].ToString()); // lt.SubItems.Add(sdr.GetString ( 2 )); lt.SubItems.Add(sdr["value"].ToString()); // Console.WriteLine(st); // Console.WriteLine(System.Text.Encoding.Default.EncodingName); //将lt数据添加到listView1控件中 listView1.Items.Add(lt); } myconn.Close(); sdr.Close(); } catch { myconn.Close(); } }
RequestBean getNextRequest() { Monitor.Enter(this); RequestBean bean = null; int modenId = -1; string portName = null; for (int i = 0; i < portNameDataGridView.RowCount - 1; i++) { if ("free" == (string)portNameDataGridView.Rows [i].Cells [1].Value) { portName = (string)portNameDataGridView.Rows [i].Cells [0].Value; modenId = i; break; } } bean = new RequestBean(); bean.modenId = modenId; bean.portName = portName; bean.batchId = 1; bean.mobileId = 1; bean.mobile = "18601345193"; Monitor.Exit(this); return(bean); if (modenId != -1 && portName != null) { MySQLConnection conn = getConn(); string sqlstr = "select * from ring_request where doing=0 order by priority desc,time limit 1"; MySQLCommand comm = new MySQLCommand(sqlstr, conn); MySQLDataReader dbReader = comm.ExecuteReaderEx(); if (dbReader.Read()) { portNameDataGridView.Rows [modenId].Cells [1].Value = "准备中....."; string sqlstr2 = "update ring_request set doing=1 where id=" + dbReader.GetInt32(0); MySQLCommand comm2 = new MySQLCommand(sqlstr2, conn); comm2.ExecuteNonQuery(); bean = new RequestBean(); bean.modenId = modenId; bean.portName = portName; bean.batchId = dbReader.GetInt32(1); bean.mobileId = dbReader.GetInt32(0); bean.mobile = dbReader.GetString(2); } dbReader.Close(); } Monitor.Exit(this); return(bean); }
private void Read(ref List <string[]> result) { oraRD = cmd.ExecuteReaderEx(); int n = oraRD.FieldCount; while (oraRD.Read()) { string[] oneResult = new string[n]; for (int i = 0; i < n; i++) { oneResult[i] = oraRD[i].ToString(); } result.Add(oneResult); } oraRD.Close(); }
/// <summary> /// Reads host and user columns from mysql database. /// </summary> public void Program() { MySQLConnection conn = new MySQLConnection(new MySQLConnectionString("localhost", "mysql", "root", "").AsString); MessageBox.Show("Connecting to database"); try { conn.Open(); } catch (Exception ex) { MessageBox.Show(ex.Message); return; } // Typical low level reading MySQLCommand cmd = new MySQLCommand("select host,user from mysql.user", conn); MySQLDataReader reader = cmd.ExecuteReaderEx(); while (reader.Read()) { ListViewItem lvi = new ListViewItem("Low Level - Host:" + reader.GetString(0) + " , User:"******"host", "user" }, new string[] { "user" }, null, null, null).Table; foreach (DataRow row in dt.Rows) { ListViewItem lvi = new ListViewItem("High Level - Host:" + row["host"].ToString() + " , User:"******"user"].ToString()); lvData.Items.Add(lvi); } MessageBox.Show("Closing database"); conn.Close(); MessageBox.Show("Read finished successfuly!"); }
/// <summary> /// Gets the data from the last active checkin today and puts it into a SCheckin struct /// </summary> /// <param name="VolunteerID">The volunteer id to search for</param> /// <returns>A SCheckin or null if there is no current checkin</returns> public SCheckin? getLastActiveTimestamp(uint VolunteerID) { //Build Query string qry = String.Format("SELECT CheckID,VolunteerID,CONCAT(DATE(TimeIn),\" \", TIME(TimeIn)),Active FROM Checkin WHERE VolunteerID={0} AND Active=1 AND DATE(TimeIn)=DATE(NOW()) ORDER BY CheckID DESC LIMIT 1;", VolunteerID); //Query Data MySQLCommand mc = new MySQLCommand(qry, vlcon); MySQLDataReader dr = mc.ExecuteReaderEx(); try { dr = mc.ExecuteReaderEx(); } catch (MySQLException) { throw new DatabaseNotOpenException(); } SCheckin rval = new SCheckin(); //int cnt = 0; try { if (dr.HasRows == false) return null; while (dr.Read()) { rval.CheckID=uint.Parse(dr.GetString(0)); rval.VolunteerID = uint.Parse(dr.GetString(1)); rval.TimeIn = dr.GetString(2); System.Console.WriteLine(rval.TimeIn); rval.Active = dr.GetString(3)=="1"?true:false; } } finally { dr.Close(); mc.Dispose(); } return rval; }
public object[][] query2d(string query) { //Query Data MySQLCommand mc = new MySQLCommand(query, vlcon); MySQLDataReader dr=null; try { dr = mc.ExecuteReaderEx(); } catch (FormatException f) { Console.WriteLine(f.Message + "|" + mc.Parameters.Count); return null; } finally { mc.Dispose(); } object[][] rv=new object[dr.RecordsAffected] []; try { for(uint i=0;dr.Read()&&dr.HasRows;i++) { rv[i] = new object[dr.FieldCount]; dr.GetValues(rv[i]); } } finally { dr.Close(); mc.Dispose(); } return rv; }
private void timer2_Tick(object sender, EventArgs e) //持續偵測 { string Tag = ""; DBConn.Open(); MySQLCommand DBComm = new MySQLCommand("select * from `parkingsystem`.`member`", DBConn); MySQLCommand firstCmd = new MySQLCommand("set names big5", DBConn); firstCmd.ExecuteNonQuery(); request("T" + (char)13); delaytime(200); String result = response(); String result1 = response1(); String result2 = response2(); string sPattern = "[\\da-fA-F]{4} [\\da-fA-F]{4} [\\da-fA-F]{4} [\\da-fA-F]{4} [\\da-fA-F]{4} [\\da-fA-F]{4}"; MatchCollection matchs = Regex.Matches(result, sPattern, RegexOptions.IgnoreCase); //抓一大段其中的一段字串 MatchCollection matchs1 = Regex.Matches(result1, sPattern, RegexOptions.IgnoreCase); MatchCollection matchs2 = Regex.Matches(result2, sPattern, RegexOptions.IgnoreCase); MySQLDataReader DBReader = DBComm.ExecuteReaderEx(); foreach (Match m in matchs) { Tag = m.Value; } int F = 0; foreach (Match m in matchs1) //1F { if (m.Value != "") { F = F + 1; //掃到 } DBReader.Read(); do { Save_state(); } while (DBReader.Read()); } tB_1F.Text = ("" + F); //message if (F >= 25) { state_1F.Text = "車位已滿"; } F = 0; foreach (Match m in matchs2) //2F { if (m.Value != "") { F = F + 1; //掃到 } DBReader.Read(); do { Save_state(); } while (DBReader.Read()); } tB_2F.Text = ("" + F); if (F >= 25) { state_2F.Text = "車位已滿"; } tSSL_state.Text = "偵測中..."; if (Tag != "") { //掃到 textBox1.Text = Tag; try { while (DBReader.Read()) { string tagstr = DBReader.GetString(1); if (textBox1.Text == tagstr) { textBox2.Text = ("" + DBReader.GetValue(2)); //MID textBox3.Text = ("" + DBReader.GetValue(3)); //carID Save_recoder(); break; } } } finally //釋放資源 { DBReader.Close(); } DBConn.Close(); } //if }
private void GetZhanMengHongBaoList(GameServerClient client, int nID, byte[] cmdParams, int count) { HongBaoListQueryData queryData = null; try { List <HongBaoSendData> list = new List <HongBaoSendData>(); queryData = DataHelper.BytesToObject <HongBaoListQueryData>(cmdParams, 0, count); if (null == queryData) { queryData = new HongBaoListQueryData(); } using (MyDbConnection3 conn = new MyDbConnection3(false)) { string cmdText; if (queryData.BhId != 0) { cmdText = string.Format("SELECT `id`,`bhid`,`senderid`,`sendername`,`sendtime`,`endtime`,`msg`,`zuanshi`,`count`,`type`,`leftzuanshi`,`leftcount`,`state` FROM `t_hongbao_send` WHERE `state`=0 AND `bhid`={0};", queryData.BhId); } else { cmdText = string.Format("SELECT `id`,`bhid`,`senderid`,`sendername`,`sendtime`,`endtime`,`msg`,`zuanshi`,`count`,`type`,`leftzuanshi`,`leftcount`,`state` FROM `t_hongbao_send` WHERE `state`=0;", new object[0]); } MySQLDataReader reader = conn.ExecuteReader(cmdText, new MySQLParameter[0]); while (reader.Read()) { list.Add(new HongBaoSendData { hongBaoID = Global.SafeConvertToInt32(reader[0].ToString(), 10), bhid = Global.SafeConvertToInt32(reader[1].ToString(), 10), senderID = Global.SafeConvertToInt32(reader[2].ToString(), 10), sender = reader[3].ToString(), sendTime = Global.SafeConvertToDateTime(reader[4].ToString(), DateTime.MinValue), endTime = Global.SafeConvertToDateTime(reader[5].ToString(), DateTime.MinValue), message = reader[6].ToString(), sumDiamondNum = Global.SafeConvertToInt32(reader[7].ToString(), 10), sumCount = Global.SafeConvertToInt32(reader[8].ToString(), 10), type = Global.SafeConvertToInt32(reader[9].ToString(), 10), leftZuanShi = Global.SafeConvertToInt32(reader[10].ToString(), 10), leftCount = Global.SafeConvertToInt32(reader[11].ToString(), 10), hongBaoStatus = Global.SafeConvertToInt32(reader[12].ToString(), 10) }); } reader.Close(); foreach (HongBaoSendData hongbao in list) { hongbao.RecvList = new List <HongBaoRecvData>(); cmdText = string.Format("SELECT `bhid`,`rid`,`rname`,`recvtime`,`zuanshi` FROM t_hongbao_recv WHERE hongbaoid={0};", hongbao.hongBaoID); MySQLDataReader mySQLDataReader; reader = (mySQLDataReader = conn.ExecuteReader(cmdText, new MySQLParameter[0])); try { while (reader.Read()) { HongBaoRecvData recvData = new HongBaoRecvData(); recvData.HongBaoID = Global.SafeConvertToInt32(reader[0].ToString(), 10); recvData.RoleId = Global.SafeConvertToInt32(reader[1].ToString(), 10); recvData.RoleName = reader[2].ToString(); recvData.RecvTime = Global.SafeConvertToDateTime(reader[3].ToString(), DateTime.MinValue); recvData.ZuanShi = Global.SafeConvertToInt32(reader[4].ToString(), 10); hongbao.RecvList.Add(recvData); } } finally { if (mySQLDataReader != null) { ((IDisposable)mySQLDataReader).Dispose(); } } } } queryData.List = list; queryData.Success = 1; } catch (Exception ex) { LogManager.WriteException(ex.ToString()); } client.sendCmd <HongBaoListQueryData>(nID, queryData); }
private void GetZhanMengHongBaoRecvList(GameServerClient client, int nID, byte[] cmdParams, int count) { HongBaoSendData data = new HongBaoSendData(); try { int hongBaoId = DataHelper.BytesToObject <int>(cmdParams, 0, count); using (MyDbConnection3 conn = new MyDbConnection3(false)) { string cmdText = string.Format("SELECT `id`,`bhid`,`senderid`,`sendername`,`sendtime`,`endtime`,`msg`,`zuanshi`,`count`,`type`,`leftzuanshi`,`leftcount`,`state` FROM `t_hongbao_send` WHERE id={0};", hongBaoId); MySQLDataReader reader = conn.ExecuteReader(cmdText, new MySQLParameter[0]); while (reader.Read()) { data.hongBaoID = Global.SafeConvertToInt32(reader[0].ToString(), 10); data.bhid = Global.SafeConvertToInt32(reader[1].ToString(), 10); data.senderID = Global.SafeConvertToInt32(reader[2].ToString(), 10); data.sender = reader[3].ToString(); data.sendTime = Global.SafeConvertToDateTime(reader[4].ToString(), DateTime.MinValue); data.endTime = Global.SafeConvertToDateTime(reader[5].ToString(), DateTime.MinValue); data.message = reader[6].ToString(); data.sumDiamondNum = Global.SafeConvertToInt32(reader[7].ToString(), 10); data.sumCount = Global.SafeConvertToInt32(reader[8].ToString(), 10); data.type = Global.SafeConvertToInt32(reader[9].ToString(), 10); data.leftZuanShi = Global.SafeConvertToInt32(reader[10].ToString(), 10); data.leftCount = Global.SafeConvertToInt32(reader[11].ToString(), 10); data.hongBaoStatus = Global.SafeConvertToInt32(reader[12].ToString(), 10); } reader.Close(); data.RecvList = new List <HongBaoRecvData>(); cmdText = string.Format("SELECT `bhid`,`rid`,`rname`,`recvtime`,`zuanshi` FROM t_hongbao_recv WHERE hongbaoid={0};", hongBaoId); MySQLDataReader mySQLDataReader; reader = (mySQLDataReader = conn.ExecuteReader(cmdText, new MySQLParameter[0])); try { while (reader.Read()) { HongBaoRecvData recvData = new HongBaoRecvData(); recvData.HongBaoID = Global.SafeConvertToInt32(reader[0].ToString(), 10); recvData.RoleId = Global.SafeConvertToInt32(reader[1].ToString(), 10); recvData.RoleName = reader[2].ToString(); recvData.RecvTime = Global.SafeConvertToDateTime(reader[3].ToString(), DateTime.MinValue); recvData.ZuanShi = Global.SafeConvertToInt32(reader[4].ToString(), 10); data.RecvList.Add(recvData); } } finally { if (mySQLDataReader != null) { ((IDisposable)mySQLDataReader).Dispose(); } } reader.Close(); } } catch (Exception ex) { LogManager.WriteException(ex.ToString()); } client.sendCmd <HongBaoSendData>(nID, data); }
private void GetZhanMengHongBaoLogList(GameServerClient client, int nID, byte[] cmdParams, int count) { List <HongBaoItemData> list = new List <HongBaoItemData>(); try { List <string> args = DataHelper.BytesToObject <List <string> >(cmdParams, 0, count); using (MyDbConnection3 conn = new MyDbConnection3(false)) { string cmdText; if (args[0] == "0") { cmdText = string.Format("SELECT hongbaoid FROM t_hongbao_recv WHERE bhid={0} AND rid={1} order by hongbaoid desc limit {2}", args[1], args[2], args[3]); List <int> hongBaoIdList = new List <int>(); MySQLDataReader reader = conn.ExecuteReader(cmdText, new MySQLParameter[0]); while (reader.Read()) { HongBaoItemData data = new HongBaoItemData(); hongBaoIdList.Add(Global.SafeConvertToInt32(reader[0].ToString(), 10)); } reader.Close(); if (hongBaoIdList.Count > 0) { cmdText = string.Format("SELECT `id`,`bhid`,`senderid`,`sendername`,`sendtime`,`endtime`,`msg`,`zuanshi`,`count`,`type`,`leftzuanshi`,`leftcount`,`state` FROM `t_hongbao_send` WHERE id IN ({0}) order by id desc;", string.Join <int>(",", hongBaoIdList)); } else { cmdText = ""; } } else if (args[0] == "1") { cmdText = string.Format("SELECT `id`,`bhid`,`senderid`,`sendername`,`sendtime`,`endtime`,`msg`,`zuanshi`,`count`,`type`,`leftzuanshi`,`leftcount`,`state` FROM `t_hongbao_send` WHERE bhid={0} AND senderid={1} order by id desc limit {2};", args[1], args[2], args[3]); } else { cmdText = string.Format("SELECT `id`,`bhid`,`senderid`,`sendername`,`sendtime`,`endtime`,`msg`,`zuanshi`,`count`,`type`,`leftzuanshi`,`leftcount`,`state` FROM `t_hongbao_send` WHERE bhid={0} order by id desc limit {2};", args[1], args[2], args[3]); } if (!string.IsNullOrEmpty(cmdText)) { MySQLDataReader reader = conn.ExecuteReader(cmdText, new MySQLParameter[0]); while (reader.Read()) { list.Add(new HongBaoItemData { hongBaoID = Global.SafeConvertToInt32(reader[0].ToString(), 10), sender = reader[3].ToString(), beginTime = Global.SafeConvertToDateTime(reader[4].ToString(), DateTime.MinValue), endTime = Global.SafeConvertToDateTime(reader[5].ToString(), DateTime.MinValue), diamondSumCount = Global.SafeConvertToInt32(reader[7].ToString(), 10), type = Global.SafeConvertToInt32(reader[9].ToString(), 10), hongBaoStatus = Global.SafeConvertToInt32(reader[12].ToString(), 10) }); } reader.Close(); foreach (HongBaoItemData data in list) { cmdText = string.Format("SELECT `zuanshi` FROM t_hongbao_recv WHERE hongbaoid={0} and rid={1};", data.hongBaoID, args[2]); MySQLDataReader mySQLDataReader; reader = (mySQLDataReader = conn.ExecuteReader(cmdText, new MySQLParameter[0])); try { if (reader.Read()) { data.diamondCount = Global.SafeConvertToInt32(reader[0].ToString(), 10); } } finally { if (mySQLDataReader != null) { ((IDisposable)mySQLDataReader).Dispose(); } } } } } } catch (Exception ex) { LogManager.WriteException(ex.ToString()); } client.sendCmd <List <HongBaoItemData> >(nID, list); }
private void Read(ref List<string[]> result) { oraRD = cmd.ExecuteReaderEx(); int n = oraRD.FieldCount; while (oraRD.Read()) { string[] oneResult = new string[n]; for (int i = 0; i < n; i++) { oneResult[i] = oraRD[i].ToString(); } result.Add(oneResult); } oraRD.Close(); }
protected void Page_Load(object sender, EventArgs e) { string strCategory = Request.QueryString["Category"].ToString(); MySQLConnection conn = new MySQLConnection(new MySQLConnectionString("192.168.1.250", "discuz_bbs", "cupid", "qweqwe123").AsString); //Response.Write("Connecting to database"); try { conn.Open(); } catch (Exception ex) { Response.Write(ex.Message); return; } MySQLCommand cmd = new MySQLCommand("set names gb2312", conn); cmd.ExecuteNonQuery(); if (strCategory == "1") { cmd = new MySQLCommand("SELECT fid,tid,author,subject,views FROM `cdb_threads` WHERE fid = 8 ORDER BY dateline DESC LIMIT 0,5", conn); //cmd = new MySQLCommand("SELECT fid,tid,author,subject,views FROM `pre_forum_thread` WHERE fid = 8 ORDER BY dateline DESC LIMIT 0,7", conn); MySQLDataReader reader = cmd.ExecuteReaderEx(); while (reader.Read()) { //Response.Write(string.Format("{0}---{1}---{2}---{3}<br>", reader["tid"], reader["author"], reader["subject"].ToString().Replace("??", "--"), reader["views"])); sb.Append(string.Format("<a target=\"_blank\" title=\"{1}\" href=\"http://192.168.1.250/viewthread.php?tid={0}&extra=page%3D1\">{2}{1}</a>\r\n", reader["tid"], reader["subject"].ToString().Replace("??", "--"), ShowFidName(reader["fid"]))); //sb.Append(string.Format("<a target=\"_blank\" title=\"{1}\" href=\"http://192.168.1.250/forum.php?mod=viewthread&tid={0}&extra=page%3D1\">{2}{1}</a>\r\n", reader["tid"], reader["subject"].ToString().Replace("??", "--"), ShowFidName(reader["fid"]))); } strContent = sb.ToString(); reader.Close(); cmd.Dispose(); conn.Close(); } if (strCategory == "11") { cmd = new MySQLCommand("SELECT fid,tid,author,subject,views FROM `cdb_threads` WHERE fid = 8 ORDER BY dateline DESC LIMIT 5,5", conn); //cmd = new MySQLCommand("SELECT fid,tid,author,subject,views FROM `pre_forum_thread` WHERE fid = 8 ORDER BY dateline DESC LIMIT 7,7", conn); MySQLDataReader reader = cmd.ExecuteReaderEx(); while (reader.Read()) { //Response.Write(string.Format("{0}---{1}---{2}---{3}<br>", reader["tid"], reader["author"], reader["subject"].ToString().Replace("??", "--"), reader["views"])); sb.Append(string.Format("<a target=\"_blank\" title=\"{1}\" href=\"http://192.168.1.250/viewthread.php?tid={0}&extra=page%3D1\">{2}{1}</a>\r\n", reader["tid"], reader["subject"].ToString().Replace("??", "--"), ShowFidName(reader["fid"]))); } strContent = sb.ToString(); reader.Close(); cmd.Dispose(); conn.Close(); } if (strCategory == "2") { cmd = new MySQLCommand("SELECT fid,tid,author,subject,views FROM `cdb_threads` WHERE fid not in (8,16,18) ORDER BY dateline DESC LIMIT 0,7", conn); //cmd = new MySQLCommand("SELECT fid,tid,author,subject,views FROM `pre_forum_thread` WHERE fid not in (8,16,18) ORDER BY dateline DESC LIMIT 0,7", conn); MySQLDataReader reader = cmd.ExecuteReaderEx(); while (reader.Read()) { //Response.Write(string.Format("{0}---{1}---{2}---{3}<br>", reader["tid"], reader["author"], reader["subject"].ToString().Replace("??", "--"), reader["views"])); sb.Append(string.Format("<a target=\"_blank\" title=\"{1}\" href=\"http://192.168.1.250/viewthread.php?tid={0}&extra=page%3D1\">{2}{1}</a>\r\n", reader["tid"], reader["subject"].ToString().Replace("??", "--"), ShowFidName(reader["fid"]))); } strContent = sb.ToString(); reader.Close(); cmd.Dispose(); conn.Close(); } if (strCategory == "3") { cmd = new MySQLCommand("SELECT fid,tid,author,subject,views FROM `cdb_threads` WHERE fid not in (8,16,18) ORDER BY dateline DESC LIMIT 7,7", conn); //cmd = new MySQLCommand("SELECT fid,tid,author,subject,views FROM `pre_forum_thread` WHERE fid not in (8,16,18) ORDER BY dateline DESC LIMIT 7,7", conn); MySQLDataReader reader = cmd.ExecuteReaderEx(); while (reader.Read()) { //Response.Write(string.Format("{0}---{1}---{2}---{3}<br>", reader["tid"], reader["author"], reader["subject"].ToString().Replace("??", "--"), reader["views"])); sb.Append(string.Format("<a target=\"_blank\" title=\"{1}\" href=\"http://192.168.1.250/viewthread.php?tid={0}&extra=page%3D1\">{2}{1}</a>\r\n", reader["tid"], reader["subject"].ToString().Replace("??", "--"), ShowFidName(reader["fid"]))); } strContent = sb.ToString(); reader.Close(); cmd.Dispose(); conn.Close(); } //huodong1 if (strCategory == "4") { cmd = new MySQLCommand("SELECT fid,tid,author,subject,views FROM `cdb_threads` WHERE fid = 18 ORDER BY dateline DESC LIMIT 0,7", conn); //cmd = new MySQLCommand("SELECT fid,tid,author,subject,views FROM `pre_forum_thread` WHERE fid = 18 ORDER BY dateline DESC LIMIT 0,7", conn); MySQLDataReader reader = cmd.ExecuteReaderEx(); while (reader.Read()) { //Response.Write(string.Format("{0}---{1}---{2}---{3}<br>", reader["tid"], reader["author"], reader["subject"].ToString().Replace("??", "--"), reader["views"])); sb.Append(string.Format("<a target=\"_blank\" title=\"{1}\" href=\"http://192.168.1.250/viewthread.php?tid={0}&extra=page%3D1\">{2}{1}</a>\r\n", reader["tid"], reader["subject"].ToString().Replace("??", "--"), ShowFidName(reader["fid"]))); } strContent = sb.ToString(); reader.Close(); cmd.Dispose(); conn.Close(); } //huodong2 if (strCategory == "5") { cmd = new MySQLCommand("SELECT fid,tid,author,subject,views FROM `cdb_threads` WHERE fid = 18 ORDER BY dateline DESC LIMIT 7,7", conn); //cmd = new MySQLCommand("SELECT fid,tid,author,subject,views FROM `pre_forum_thread` WHERE fid = 18 ORDER BY dateline DESC LIMIT 7,7", conn); MySQLDataReader reader = cmd.ExecuteReaderEx(); while (reader.Read()) { //Response.Write(string.Format("{0}---{1}---{2}---{3}<br>", reader["tid"], reader["author"], reader["subject"].ToString().Replace("??", "--"), reader["views"])); sb.Append(string.Format("<a target=\"_blank\" title=\"{1}\" href=\"http://192.168.1.250/viewthread.php?tid={0}&extra=page%3D1\">{2}{1}</a>\r\n", reader["tid"], reader["subject"].ToString().Replace("??", "--"), ShowFidName(reader["fid"]))); } strContent = sb.ToString(); reader.Close(); cmd.Dispose(); conn.Close(); } //MySQLCommand commn = new MySQLCommand("set names gb2312", conn); //commn.ExecuteNonQuery(); //DataTable dt = new MySQLSelectCommand(conn, new string[] { "tid", "author", "subject", "views" }, new string[] { "cdb_threads" }, null, null, null, true, 0, 10, false).Table; //foreach (DataRow row in dt.Rows) //{ // Response.Write(string.Format("{0}---{1}---{2}---{3}", row["tid"], row["author"], row["subject"], row["views"])); //} //dt.Dispose(); //commn.Dispose(); }