vs连接SQL server 的语句

        static public DataTable db()     

    {           

            DataTable dt = new DataTable();       

            string sql = "select [XX],[XXXX from [数据库名称].[dbo].[表名称] where 列名='列名中一项名称'";       

            SqlConnection conn = new SqlConnection( "server=.;database =数据库名称;integrated security=SSPI");     

            conn.Open();        

            SqlCommand cmd = new SqlCommand(sql,conn);   

            SqlDataAdapter da = new SqlDataAdapter(cmd);

            da.Fill(dt);

            return dt;

        }

posted @ 2018-02-28 10:05  念秋竹  阅读(383)  评论(0编辑  收藏  举报