Beispiel #1
0
        public KeyValue GetResult(string sqlcomand, SqlConnection conn)
        {
            SqlCommand cmd = new SqlCommand(sqlcomand, conn);

            SqlDataAdapter adapter = new SqlDataAdapter(cmd);

            DataSet ds = new DataSet();

            adapter.Fill(ds);//填充数据

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(ModelConvertHelper <KeyValue> .ToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
Beispiel #2
0
        public T GetResult <T>(string sqlcomand, SqlConnection conn) where T : new()
        {
            SqlCommand cmd = new SqlCommand(sqlcomand, conn);

            SqlDataAdapter adapter = new SqlDataAdapter(cmd);

            DataSet ds = new DataSet();

            adapter.Fill(ds);//填充数据


            if (ds.Tables[0].Rows.Count > 0)
            {
                return(ModelConvertHelper <T> .ToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(default(T));
            }
        }