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>

      

  • 相关阅读:
    jdbc练习demo
    需登录账号与密码的网页爬取demo
    获取中文的首字母demo
    短信发送接口demo
    读取配置文件工具demo
    省选模拟96
    省选模拟95
    省选模拟94
    省选模拟92
    省选模拟91
  • 原文地址:https://www.cnblogs.com/hellowzd/p/4335793.html
Copyright © 2011-2022 走看看