string strConn = "", strUserID = "", strUserName = "";
                strConn = ConfigurationManager.AppSettings["strConn"];
                SqlConnection ObjConn = new SqlConnection(strConn);
                SqlDataAdapter ObjCmd = new SqlDataAdapter("select UserID from RegInfo where TeamName='" + txtTeamName.Text.Trim() + "' ", ObjConn);
                DataSet ObjDS = new DataSet();
                ObjCmd.Fill(ObjDS, "RegInfo");
                for (int i = 0; i < ObjDS.Tables["RegInfo"].Rows.Count; i++)
                {
                    strUserID = ObjDS.Tables["RegInfo"].Rows[i]["UserID"].ToString();//資料一筆一筆存入StrUserID

                    if(strUserName!="")
                    {
                        //資料一筆一筆比對
                        strUserName = strUserName +"\\n"+ objFun.GetValues("select UserName from UserInfo where ID='" + strUserID + "'", "UserName");
                    }
                    else
                    {
                        //資料一筆一筆比對
                        strUserName = objFun.GetValues("select UserName from UserInfo where ID='" + strUserID + "'", "UserName");
                    }
                }
                ObjConn.Dispose();
                ObjCmd.Dispose();
                ObjDS.Dispose();

魔法魚 發表在 痞客邦 PIXNET 留言(0) 人氣()