投票系统前台 C#,数据库SQL
------------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的更多相关文章
- SSM框架整合项目 :投票系统
框架: Spring SpringMVC MyBatis 题目: 投票系统 导包: 1, spring 2, MyBatis 3, mybatis-spring 4, fastjson 5, aspe ...
- SSM demo :投票系统
框架: Spring SpringMVC MyBatis 题目: 投票系统 导包: 1, spring 2, MyBatis 3, mybatis-spring 4, fastjson 5, aspe ...
- Django写的投票系统2(转)
在上一篇中 django实例:创建你的第一个应用投票系统(一) 已经介绍基本的功能,并已经启动服务了.这一节介绍数据库相关的东东. 首页打开mysite/settings.py配置文件, 设置数据库打 ...
- Django写的投票系统1(转)
当然主要是从django的帮助文档里面来的,权当是翻译吧 这个投票系统的主要功能有 1.一个前台页面,可以让用户来投票 2.一个管理员页面,可以用来添加.修改.删除投票 首页第一步要确定你已经安装了D ...
- log4j向oracle中插入一条系统当前时间的sql语句
配置log4j,要向oracle插入一条系统当前时间的sql语句,按网上查找的总是出现各种各样的报错,最后总结出的写法是: ### shezhi### log4j.rootLogger = debug ...
- Django快速开发之投票系统
https://docs.djangoproject.com/en/1.8/intro/tutorial01/ 参考官网文档,创建投票系统. ================ Windows 7/1 ...
- Android 系统API实现数据库的增删改查和SQLite3工具的使用
在<Android SQL语句实现数据库的增删改查>中介绍了使用sql语句来实现数据库的增删改查操作,本文介绍Android 系统API实现数据库的增删改查和SQLite3工具的使用. 系 ...
- linux系统上Mysql数据库导入导出操作
需求:把MySQL数据库目录中的dz数据库备份到/home/dz_bak.sql ,然后再新建一个数据库dzbak,最后把/home/dz_bak.sql 导入到数据库dzbak中.操作如下:以下操作 ...
- 数据库 SQL语句优化
温馨提示:本篇内容均来自网上,本人只做了稍微处理,未进行细致研究,仅当做以后不备之需,如若你喜欢可尽情转走. 一.问题的提出 在应用系统开发初期,由于开发数据库数据比较少,对于查询SQL语句,复杂视图 ...
随机推荐
- 苹果 App 转移图文详解
目前公司在做App转移操作,在网上搜索相关资料加上自己的亲自操作,整理成一个文档,希望能给你提供帮助. 如转载请添加出处. 此文章只是为了记录一个Apple ID下的APP,转移到另外一个Apple ...
- 让微信二维码扫描你的APK
二维码深入人心,很多App都在官网挂出了可以扫描下载apk的二维码,笔者所在公司的产品也不例外.一般二维码编码的URL不会直接放apk而是放中间地址,通过这个中间地址再跳转到apk所在URL,原因大概 ...
- ##DAY2 UILabel、UITextField、UIButton、UIImageView、UISlider
##DAY2 UILabel.UITextField.UIButton.UIImageView.UISlider #pragma mark ———————UILabel——————————— UILa ...
- asp.net 分页的制作
/// <summary> /// 数据分页方法 /// </summary> /// <param name="PageIndex">当前页& ...
- Linux内核学习笔记-2.进程管理
原创文章,转载请注明:Linux内核学习笔记-2.进程管理) By Lucio.Yang 部分内容来自:Linux Kernel Development(Third Edition),Robert L ...
- html 表头固定
<div style="width: 100%; min-width: 300px; padding-right: 10px;"> <table style=&q ...
- zoj 3195 Design the city lca倍增
题目链接 给一棵树, m个询问, 每个询问给出3个点, 求这三个点之间的最短距离. 其实就是两两之间的最短距离加起来除2. 倍增的lca模板 #include <iostream> #in ...
- A Byte of Python 笔记(12)python 标准库:sys、os,更多内容
第14章 python 标准库 Python标准库是随Python附带安装的,它包含大量极其有用的模块. sys 模块 sys 模块包含系统对应的功能.如 sys.argv 列表包含命令行参数. # ...
- InfoQ文章
http://www.infoq.com/cn/presentations/log-platform-construction-weipinhui https://github.com/Telesco ...
- Windows Azure 存储的冗余存储选项和只读访问跨地域冗余存储
我们很高兴地宣布,现在我们使客户可以获得对数据更高的读取可用性.该预览功能称为"只读访问- 跨地域冗余存储(RA-GRS)",使客户可以在存储帐户主要区域无法读取数据时,通过跨 ...