------------vote.aspx.cs--------------------
  private void Page_Load(object sender, System.EventArgs e)   {    // 在此处放置用户代码以初始化页面    if(!Page.IsPostBack)    {     SqlConnection con=db.createrConnection();     con.Open();     SqlCommand cmd=new SqlCommand("select votetitle from votemaster where voteid="+this.idd,con);     string title=Convert.ToString(cmd.ExecuteScalar());     this.title.Text=title;     cmd.CommandText="select * from vote where voteid="+this.idd;     SqlDataReader sdr=cmd.ExecuteReader();     this.rad.DataSource=sdr;     this.rad.DataTextField="voteitem";     this.rad.DataValueField="id";     this.rad.DataBind();     sdr.Close();     con.Close();    }   } 窗体代码 private void tp_Click(object sender, System.EventArgs e)   {   SqlConnection con=db.createrConnection();   con.Open();   SqlCommand cmd=new SqlCommand();   cmd.Connection=con;   cmd.CommandText="update vote set votenun=votenun+1 where voteid="+this.idd+" and id="+this.rad.SelectedValue.ToString();   cmd.ExecuteNonQuery();  con.Close();

}

private void show_Click(object sender, System.EventArgs e)   {    Response.Redirect("show.aspx?voteid="+this.idd);   }  } } ---------------------完----------vote.aspx -----------------

Label
 
 

------------------------------完-----------db.cs-----------------------

// TODO: 在此处添加构造函数逻辑
   //
  }
  public static SqlConnection createrConnection()
  {
 SqlConnection con=new SqlConnection("server=.;database=vote;uid=sa;pwd=980123");
  return con;
  }
 }
}
------------------------show.aspx.cs--------------------------
private void Page_Load(object sender, System.EventArgs e)
  {
   string id=Request.QueryString["voteid"].ToString();
   SqlConnection con=db.createrConnection();
   con.Open();
   SqlCommand cmd=new SqlCommand("select * from vote where voteid="+id,con);
   SqlDataReader sdr=cmd.ExecuteReader();
   while (sdr.Read())
  {
  Response.Write(sdr.GetString(2)+"--"+sdr.GetInt32(3).ToString());
  }
---------------------完-------------sql文件------------------

create database vote

use vote

create table votemaster ( voteid int primary key,--投票编号 votetitle varchar(100) not null,--投票标题 votesum int default 0 --投票的总票数 )

insert into votemaster values(1,'书记选举',0) insert into votemaster values(2,'市长选举',0)

select * from votemaster

create table vote (  voteid int foreign key references votemaster(voteid),--该键是主表的联系键  id int not null,  voteitem varchar(20) not null,  votenun int default 0, )

insert into vote values(1,1,'张三',0) insert into vote values(1,2,'李达',0) insert into vote values(1,3,'钟馗',0) insert into vote values(1,4,'江尚',0) insert into vote values(2,1,'刘文采',0) insert into vote values(2,2,'李世民',0) insert into vote values(2,3,'周正',0) insert into vote values(2,4,'张三疯',0)

select * from vote where voteid=2

create trigger updatemaster--这里是触发器 on vote for update as begin   update votemaster set votesum=votesum+1 where voteid=(select top 1 voteid from inserted) end

update vote set votenun=votenun+1 where voteid=2 and id=2
------------------------------完--------------------

投票系统前台 C#,数据库SQL的更多相关文章

  1. SSM框架整合项目 :投票系统

    框架: Spring SpringMVC MyBatis 题目: 投票系统 导包: 1, spring 2, MyBatis 3, mybatis-spring 4, fastjson 5, aspe ...

  2. SSM demo :投票系统

    框架: Spring SpringMVC MyBatis 题目: 投票系统 导包: 1, spring 2, MyBatis 3, mybatis-spring 4, fastjson 5, aspe ...

  3. Django写的投票系统2(转)

    在上一篇中 django实例:创建你的第一个应用投票系统(一) 已经介绍基本的功能,并已经启动服务了.这一节介绍数据库相关的东东. 首页打开mysite/settings.py配置文件, 设置数据库打 ...

  4. Django写的投票系统1(转)

    当然主要是从django的帮助文档里面来的,权当是翻译吧 这个投票系统的主要功能有 1.一个前台页面,可以让用户来投票 2.一个管理员页面,可以用来添加.修改.删除投票 首页第一步要确定你已经安装了D ...

  5. log4j向oracle中插入一条系统当前时间的sql语句

    配置log4j,要向oracle插入一条系统当前时间的sql语句,按网上查找的总是出现各种各样的报错,最后总结出的写法是: ### shezhi### log4j.rootLogger = debug ...

  6. Django快速开发之投票系统

    https://docs.djangoproject.com/en/1.8/intro/tutorial01/ 参考官网文档,创建投票系统. ================ Windows  7/1 ...

  7. Android 系统API实现数据库的增删改查和SQLite3工具的使用

    在<Android SQL语句实现数据库的增删改查>中介绍了使用sql语句来实现数据库的增删改查操作,本文介绍Android 系统API实现数据库的增删改查和SQLite3工具的使用. 系 ...

  8. linux系统上Mysql数据库导入导出操作

    需求:把MySQL数据库目录中的dz数据库备份到/home/dz_bak.sql ,然后再新建一个数据库dzbak,最后把/home/dz_bak.sql 导入到数据库dzbak中.操作如下:以下操作 ...

  9. 数据库 SQL语句优化

    温馨提示:本篇内容均来自网上,本人只做了稍微处理,未进行细致研究,仅当做以后不备之需,如若你喜欢可尽情转走. 一.问题的提出 在应用系统开发初期,由于开发数据库数据比较少,对于查询SQL语句,复杂视图 ...

随机推荐

  1. 使用资源监控工具 glances

    http://www.ibm.com/developerworks/cn/linux/1304_caoyq_glances/ glances 可以为 Unix 和 Linux 性能专家提供监视和分析性 ...

  2. j详细说明ava于clone办法

    原文地址:http://leihuang.org/2014/11/14/java-clone/ In java, it essentially means the ability to create ...

  3. Android 支付宝钱包手势password裂纹战斗

    底 随着移动互联网和手机屏幕越做越大的普及等..购物在移动设备上.消费是必不可少的人们习惯于生活. 随着这股浪潮的兴起,安全.便捷的移动支付的需求也越来越大.故,各大互联网公司纷纷推出了移动支付平台. ...

  4. App引导页面源代码的实现

    一.页面效果图

  5. 第八章 C#面向对象编程(Object-Oriented Programming,OOP)简介

    .NET OOP 一.面向对象编程的含义 1.函数(过程化)编程常常导致单一的应用程序,即所有的功能都包含在几个代码模块中(常常是一个代码模块) 而使用OOP技术,常常使用许多代码模块,每个模块提供特 ...

  6. Linux(Debain)环境安装WordPress

    一.相关组件安装 1. 安装Apache apt-get install apache2 安装完毕后浏览器 http://localhost/ 或者 http://127.0.0.1 出现It Wor ...

  7. JS学习之事件冒泡

    (1)什么是事件起泡      首先你要明白一点,当一个事件发生的时候,该事件总是有一个事件源,即引发这个事件的对象,一个事件不能凭空产生,这就是事件的发生. 当事件发生后,这个事件就要开始传播.为什 ...

  8. java中对象模型与数据库中的关系模型

    实体类还需要配置到hibernate.cfg.xml中,以便Hibernate初始化实体类与数据库表的映射关系.如果只配置了映射关系,而没有配置到hibernate.cfg.xml中,Hibernat ...

  9. Python学习笔记 (3) :列表、元组的操作

    列表,即写在方括号之间.用逗号分隔开的数值列表.列表内的项目不必全是相同的类型. >>> a = ['spam', 'eggs', 100, 1234] >>> a ...

  10. poj 2653 计算几何

    #include <iostream> #include <cstring> #include <algorithm> #include <cmath> ...