简单的sql server连接

        private string constring="data source=112.74.73.122;initial catalog=qzyData;user id=sa;password=11111111";

        //18经度
        //19纬度
        private string FindUserMobilephone( )
        {
            string strCmd;
            string phone = "";

            strCmd = "select * from QZY_sites";
            //PublicFunction.WriteLog("123: ", strCmd);
            SqlConnection conn = new SqlConnection();
            conn.ConnectionString = constring;
            try
            {
                conn.Open();
                SqlCommand cmd = new SqlCommand(strCmd, conn);
                SqlDataReader rr = cmd.ExecuteReader();

                while (rr.Read())
                {
                    phone += rr[1].ToString();
                }
            }
            catch (SqlException sqle)
            {
                //PublicFunction.WriteLog("456: ", sqle.Message);
            }
            return phone;
        }

 

posted @ 2016-12-13 00:27  兜兜丨有糖丶  阅读(145)  评论(0编辑  收藏  举报