C#打包SQL数据库部署安装
参考《ASP.NET与SQL一起打包部署安装》
,这篇文章是针对VB.NET与SQL 一起打包的,但是我使用的是C#,当然只要修改一下主要安装类库就行了!C#的类库代码如下:DBCustomAction.cs
using System;
using System.Collections;
using System.Data.SqlClient;
using System.ComponentModel;
using System.Configuration.Install;
using System.Diagnostics;
using System.IO;
using System.Xml;
using System.Reflection;
namespace PMS
{
/// <summary>
/// DBCustomAction 的摘要说明。
/// </summary>
[RunInstaller(true)]
public class DBCustomAction : System.Configuration.Install.Installer
{
/// <summary>
/// 必需的设计器变量。
/// </summary>
private System.ComponentModel.Container components = null;
public DBCustomAction()
{
// 该调用是设计器所必需的。
InitializeComponent();
// TODO: 在 InitializeComponent 调用后添加任何初始化
}
private void ExecuteSql(string conn,string DatabaseName,string Sql)
{
SqlConnection mySqlConnection=new SqlConnection(conn);
SqlCommand Command=new SqlCommand(Sql, mySqlConnection);
mySqlConnection.Open();
mySqlConnection.ChangeDatabase(DatabaseName);
try
{
Command.ExecuteNonQuery();
}
finally
{
//close Connection
mySqlConnection.Close();
}
}
/// <summary>
/// 清理所有正在使用的资源。
/// </summary>
protected override void Dispose( bool disposing )
{
if( disposing )
相关文档:
系统环境:Windows 7
软件环境:Visual C++ 2008 SP1 +SQL Server 2005
本次目的:编写一个航空管理系统
这是数据库课程设计的成果,虽然成绩不佳,但是作为我用VC++ 以来编写的最大程序还是传到网上,以供参考。用VC++ 做数据库设计并不容易,但也不是不可能。以下是我的程序界面,后面 ......
if exists(select * from sysobjects where name='atzk')--判断是否存在此表
drop table atzk
go
create table atzk
(
nid int identity(1,1) primary key,--nid自动编号,并设为主键。
mytitle varchar(50) not null,--通知的标题。
mycontents varchar(200)--发布通知的内容。
) ......
转自:http://book.csdn.net/bookfiles/235/10023510864.shtml
在实际SQL应用中,经常需要进行分组聚合,即将查询对象按一定条件分组,然后对每一个组进行聚合分析。
GROUP BY子句创建分组
创建分组是通过GROUP BY子句实现的。与WHERE子句不同,GROUP BY子句用于归纳信息类型,以汇总相关数据。而为什么要使用GROUP BY ......
新建表:
create table [表名]
(
[自动编号字段] int IDENTITY (1,1) PRIMARY KEY ,
[字段1] nVarChar(50) default '默认值' null ,
[字段2] ntext null ,
[字段3] datetime,
[字段4] money null ,
[字段5] int default 0,
[字段6] Decimal (12,4) default 0,
[字段7] image null ,
)
删除表:
Drop table [表 ......
一 单词解释(2分/个) 34分
Data 数据 Database 数据库 RDBMS 关系数据库管理系统 GRANT 授权
REVOKE 取消权限 DENY 拒绝权限 DECLARE 定义变量 PROCEDURE存储过程
事务 Transaction 触发器 TRIGGER 继续 continue 唯一 unqiue
主键 primary key 标识列 identity 外键 foreign key 检 ......