zoukankan      html  css  js  c++  java
  • 查询

    控制层

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.Mvc;
    
    using System.Data;
    using System.Data.SqlClient;
    
    
    namespace MvcApplication5.Controllers
    {
    
         
        public class TestController : Controller
        {
            //
            // GET: /Test/
        
            public ActionResult Index()
            {
           
                SqlConnection conn = new SqlConnection("server=.;database=AAA;Integrated Security=True");
                conn.Open();
                SqlCommand data = new SqlCommand("select COUNT(*) ABC from haha ", conn);
                //var mc =data.ExecuteReader();
                SqlDataReader dr = data.ExecuteReader();
                while (dr.Read()) //读取信息
                {
                    ViewData["Message"] = dr["ABC"].ToString();
    
                }
              
                conn.Close();
                return View();
                
                
            }
    
        }
    }

    显示层

    <%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<dynamic>" %>
    
    <asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    
      <%:ViewData["Message"] %>
    
    </asp:Content>

      

  • 相关阅读:
    浅谈数组
    前端冷知识
    number框
    jQuery封装轮播图插件
    瀑布流的简单制作
    Java script-数组与字符串方法
    Java script-1
    Web前端基础学习-2
    Web前端基础学习-3
    Web前端基础学习-1
  • 原文地址:https://www.cnblogs.com/hellowzd/p/4335793.html
Copyright © 2011-2022 走看看