Exemplo n.º 1
0
        private bool LoadFriendID()
        {
            bool          state             = true;
            SqlConnection GetFriendInfoConn = new SqlConnection(connstring);
            string        GetFriendList     = string.Format("select * from friends where id='{0}'", myInfo.id);//首先获取好友的id信息
            SqlCommand    GetFriendListComm = new SqlCommand(GetFriendList, GetFriendInfoConn);
            SqlDataReader FriendListData;

            try
            {
                GetFriendInfoConn.Open();
                FriendListData = GetFriendListComm.ExecuteReader();
                if (FriendListData.Read())
                {
                    FriendsNum = (int)FriendListData[1];
                    FriendInfo = new InfoofFriend[FriendsNum];
                    for (int i = 0; i < FriendsNum; i++)
                    {
                        FriendInfo[i]    = new InfoofFriend();
                        FriendInfo[i].id = FriendListData[i + 2].ToString();
                    }
                }
                else
                {
                    state = false;
                }
                FriendListData.Close();
                GetFriendInfoConn.Close();
            }
            catch (Exception str)
            {
                MessageBox.Show("Error: " + str.Message, "获取好友ID错误");
                state = false;
            }
            return(state);
        }
Exemplo n.º 2
0
        private bool LoadFriendID()
        {
            bool state = true;
            SqlConnection GetFriendInfoConn = new SqlConnection(connstring);
            string GetFriendList = string.Format("select * from friends where id='{0}'", myInfo.id);//首先获取好友的id信息
            SqlCommand GetFriendListComm = new SqlCommand(GetFriendList, GetFriendInfoConn);
            SqlDataReader FriendListData;
            try
            {
                GetFriendInfoConn.Open();
                FriendListData = GetFriendListComm.ExecuteReader();
                if (FriendListData.Read())
                {
                    FriendsNum = (int)FriendListData[1];
                    FriendInfo = new InfoofFriend[FriendsNum];
                    for (int i = 0; i < FriendsNum; i++)
                    {
                        FriendInfo[i] = new InfoofFriend();
                        FriendInfo[i].id = FriendListData[i + 2].ToString();
                    }

                }
                else
                {
                    state = false;
                }
                FriendListData.Close();
                GetFriendInfoConn.Close();
            }
            catch (Exception str)
            {
                MessageBox.Show("Error: " + str.Message, "获取好友ID错误");
                state = false;
            }
            return state;
        }