05 2010 档案
摘要:2010年5月21日星期五
设有关系模式:EMP(职工号,姓名,工资,部门号)
试用SQL语句创建一个工资总额超过20万元(含20万元)的各部门工资总额视图V-SAL。
select 部门号,sum(工资) as 总工资 from emp group by 部门号 having sum(工资)>=20
CREATE VIEW dbo.[V-SAL]
AS
SELECT 部门号, SUM(工资) AS 总工资
FROM dbo.EMP
GROUP BY 部门号
HAVING (SUM(工资) >= 20)
阅读全文
摘要:/*用触发器来实现级联更新级联删除*/
--创建学生表,课程表,学生课程表
--http://www.yaosansi.com/post/692.html
范本:
触发器方式:
create trigger trg_A
on A
for update,delete
as
begin
if exists(select 1 from inserted)
update B set Name=(select Name from inserted) where Name=(select Name from deleted)
else
delete B where Name=(select Name from deleted)
end
go
下面是一个实例:
CREATE TABLE [dbo].[学生表](
[studentid] [nvarchar](50) primary key NOT NULL,
[name] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL,
)
CREATE TABLE [d
阅读全文
摘要:参考网站:
http://www.phpchina.com/manual/PostgreSQL/ddl-constraints.html
/*
创建级联更新,级联删除操作
author: dingdang
time :20100520
**/
--创建表
CREATE TABLE products (
product_no integer PRIMARY KEY,
name text,
price numeric
);
CREATE TABLE orders (
order_id integer PRIMARY KEY,
shipping_address text,
-- ...
);
/*
CREATE TABLE order_items (
阅读全文
摘要:我的操作系统为Windows 2003 Server , 文件系统NTFS, 在SQL Server 2005 Express 上附加(Attach)从另外一台电脑Copy过来的数据库后,数据库为“只读”。
总结:之所以附加(Attach)上的数据库为“只读”,是因为启动SQL Server 的默认的启动帐号“网络服务”对所附加(Attach)的数据库文件的权限不够造成的。
阅读全文
摘要:2010年5月14日星期五
Oracle数据的备份与还原
资料引用:http://www.knowsky.com/384957.html
数据的备份
1 将数据库orcl完全导出,用户名scott 密码tiger 导出到D:\daochu.dmp中
exp scott/tiger@orcl file=d:\daochu.dmp full=y
2 将数据库中system用户与sys用户的表导出
exp scott/tiger@orcl file=d:\daochu.dmp owner=(scott)
3 将数据库中的表inner_notify、notify_staff_relat导出
Exp scott/tiger@orcl file= d:\daochu.dmp tables=(inner_notify,notify_staff_relat)
数据的导入
1.imp scott/tiger@orcl file=d:\daochu.dmp full=y
imp scott/tiger@orcl full=y file= d:\daochu.
阅读全文
摘要:2010年5月13日星期四
赋权限给oralce新建的用户
grant connect to XX;
grant exp_full_database to XX;
grant imp_full_database to XX;
grant resource to XX;
grant create procedure to XX;
grant create trigger to XX;
grant execute any procedure to XX;
grant grant any privilege to XX;
grant restricted session to XX;
grant select any table to XX;
grant unlimited tablespace to XX;
grant create any view to XX;
阅读全文
摘要:用代码来实现oracle自动增加1功能
创建序列:-- Create sequence
create sequence IP_Test_SEQUENCES
minvalue 1
maxvalue 99999999999999999999999999
start with 1
increment by 1
cache 20
order;
创建触发器:
create or replace trigger IP_Test_Trigger
before insert on ip_test
for each row
declare
-- local variables here
next_id number;
begin
select IP_Test_Sequences.nextval into next_id from dual;
:new.id:=next_id;
--select IP_Test_Sequences.nextval into :new.id from dual;
end IP_Test_Trigger;
阅读全文
摘要:oracle11g客户端-配置
首先配置:Net Configuration Assistant
一般在应用中配置监听程序配置和本地Net服务名配置:
再次配置:Net Manager
说是配置,打开它以后,就可以看到上面配置的net服务名,在这里可以进行测试。
阅读全文
摘要:怎么使程序与服务器上的oracle11g进行通信呢。我们不能不再提SQLServer2000是如何与服务器上的数据库进行通信的呢。当用ASP.net进行程序开发时,我们在Webconfig中配置连接服务器上的SQLServer 连接字符串这样,就可以连接服务器上的数据库了。而在oracle11g中要安装oracle11g客户端软件,在客户端进行连接配置,这样才能与服务器通信。
从网上下载oracle11g客户端,安装后弹出下列选择框,当要在客户端开发连接oracle11g数据库的程序。应该选择下面的运行时,看它的提示:安装用于开发应用程序,网络服务等。
阅读全文
摘要:Oracle11g中,设置主键为自增1形式-创建Trigger
阅读全文
摘要:Oracle11g中,设置主键为自增1形式-创建序列
阅读全文
摘要:Oracle11g创建数据库
如何在是11g中创建数据库,这对于初学者是很重要的。当我们初学oracle11g时,安装后,机器中运行的是oracle11g默认安装的orcl数据库。这个数据库可以当作我们学习oracle数据库时的练习数据库。但在实际项目中,我们应该建立自己的数据库。
在oracle11g新建数据库,按如下步骤:配置和移植工具->Administration Assistant for windows.然后按照下面的提示一步一步做下去,可以使用默认的配置,也可以自定义配置。
当新建立完数据库,会在最后一地,加一个DataBase Control-xx,后面是你新建立的一个数据库名。
对orcle11g数据库深一步理解:我想这个应该是和Microsoft SQLServer 类似的吧。但也有所不同。一样的是,他们都以某种形式,以Windows的一种服务来存在;不同的是,SQLServer,各种数据库都以一个Windows服务来存在,而在oracle11g中每一个数据库在Windows 服务中都以数据库形式服务存在。
阅读全文
摘要://获得数据库连接字符串
void CMFCSQLDlg::OnConnStrClick()
{
// TODO: Add your control notification handler code here
HRESULT hr; //返回结果变量
_ConnectionPtr m_pConnection;
// 在应用程序的InitInstance函数里加入
CoInitialize(NULL) ;
hr=m_pConnection.CreateInstance("ADODB.Connection"); //创建Connection对象
if(SUCCEEDED(hr))
{
CStdioFile mFile;
CString connstr="";
mFile.Open("a.txt",CFile::modeRead);
if(mFile.ReadString(connstr))
MessageBox("获得SQL字符串!","成功",MB_OK);
m_pConnection->Open((_bstr_t)conn
阅读全文
摘要:unresolved external symbol _TIFFOpen
这应该是在Windows32 console application,想进行libtiff文件的配置,我一开始也是这么做的了,就是出现了unresolved external symbol _TIFFOpen,在网上搜了很多资料,也都大部分指出是不是external 出现了问题,也没有找到相应的结果。
后来,自己新建立了支持MFC的Windows32 console application的项目,这样在用libtiff在Dos下相表现出读出tiff文件的一些性质.
阅读全文
摘要:Visual C++用libtiff对tiff文件进行操作.
对libtiff文件的配置。
1. 工程->设置->资源->附加资源包含路径,填写”libtiffd.lib”,因名字问题,你需要的是你打包的文件名,或是”libtiff.lib”,要把系统用到libtiff中的头文件加到项目路径下如:tiff.h,tiffconf.h,tiffio.h,tiffiop.h,tiffvers.h,在主程序下需要添加头文件#include "tiffio.h"来调用相关的类。
2. 工程->设置->连接->对象/库模块,在最后添加上libtiffd.lib
对libtiff的lib和dll文件下载可以参考:
http://download.csdn.net/source/2325871
阅读全文
摘要:Web页面根据不同的分辨率显示不同的图片
阅读全文
摘要:///
///导出Excel
///
///
///
protected void ToExcel2()
{
// Response.Clear();
Response.AddHeader("content-disposition", "attachment;filename=FileName.xls");
Response.Charset = "gb2312";
Response.ContentType = "application/vnd.xls";
Response.ContentEncoding = System.Text.Encoding.UTF8;
System.IO.StringWriter stringWrite = new System.IO.Stri
阅读全文
摘要:当用GridView导出Execl的时候,会发生只能在执行 Render() 的过程中调用 RegisterForEventValidation的错误提示。
有两种方法可以解决以上问题:
1.修改web.config(不推荐)
2.直接在导出Execl的页面修改
阅读全文
摘要:更新方法一,直接在GridView中来更新数据.
更新方法二,打开一个新的页面来更新数据.
//更新
protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
{
GridView1.EditIndex = e.NewEditIndex;
//PopulatePublishersGridView();
string sqlstr = getSQlStr();
bind(sqlstr);
}
//更新
protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
OleDbConnection sqlcon = new OleDbConnection(GetConnection());
string sqlstr =
阅读全文
摘要:根据主键来删除表中的数据。
//删除
protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
OleDbConnection sqlConnection = new OleDbConnection(GetConnection());
string sqlstr = "delete from MResume where id=" + GridView1.DataKeys[e.RowIndex].Value.ToString() + "";
OleDbCommand sqlcom = new OleDbCommand(sqlstr, sqlConnection);
sqlConnection.Open();
sqlcom.ExecuteNonQuery();
sqlConnection.Close();
//PopulatePubli
阅读全文
摘要:///
/// 分页技术,触发事件
///
///
///
protected void gridViewPublishers_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
GridView1.DataSource = SortDataTable(GridView1.DataSource as DataTable, true);
GridView1.PageIndex = e.NewPageIndex;
GridView1.DataBind();
}
///
/// 分页实现
///
/// param name="da
阅读全文
摘要:GridView绑定数据.
//绑定
public void bind(string str)
{
string oledbstr = "";
if (str != null && str != "")
{
oledbstr = str;
}
else
{
oledbstr = "select ID, 姓名,性别,出生日期,工作年限,证件类型,证件号,居住地,Email,手机号码,家庭电话,自我评价 from MResume order by id desc";
}
OleDbConnection oledbcon = new OleDbConnection(GetConnection());
OleDbDataAdapter myda = new OleDbDataAdapter(oledbstr, oledbcon);
DataSet
阅读全文
摘要:Web.config配置
appSettings中配置access与sqlserver
/appSettings
阅读全文
摘要:/*
*SQLServer添加操作实现
*/
void CMFCSQLDlg::OnButton2()
{
// TODO: Add your control notification handler code here
CString strsql;
CString strnum="mynum3";
CString strage="myage3";
HRESULT hResult;
_variant_t RecordsAffected;
CoInitialize(NULL);
_ConnectionPtr m_pAppConn;
hResult = m_pAppConn.CreateInstance(("ADODB.Connection"));///创建Connection对象
if(SUCCEEDED(hResult))
{
//m_pAppConn->Open("Provider=Microsoft.Jet.OLEDB.4.0 ;Data Source = .\\DataBase\\aa.mdb", "","",adModeUnkno
阅读全文
摘要:/*
*连接SQL
*/
void CMFCSQLDlg::OnButton3()
{
// TODO: Add your control notification handler code here
_ConnectionPtr m_pConnection;
// 在应用程序的InitInstance函数里加入
if(S_OK!=CoInitialize(NULL))
{
AfxMessageBox("初始化COM库错误!");
}else
{
AfxMessageBox("初始化COM库成功!");
}
// 连接数据库:
HRESULT hr; //返回结果变量
try
{
hr=m_pConnection.CreateInstance("ADODB.Connection"); //创建Connection对象
if(SUCCEEDED(hr))
{
//hr=m_pCo
阅读全文
摘要:/*
*读取Access数据库中的数据
*/
void CMFCSQLDlg::OnButton1()
{
CoInitialize(NULL);
_ConnectionPtr m_pAppConn;
HRESULT hResult;
try
{
hResult = m_pAppConn.CreateInstance(("ADODB.Connection"));///创建Connection对象
if(SUCCEEDED(hResult))
{
m_pAppConn->Open("Provider=Microsoft.Jet.OLEDB.4.0 ;Data Source = .\\DataBase\\aa.mdb", "","",adModeUnknown);
}
_CommandPtr m_pCommand;
_RecordsetPtr m_pRecordset;
m_pCommand.CreateInstance("ADODB.Command");
_var
阅读全文
摘要:在用vc编写数据库连接程序时,经常会犯的一个错误。WINDOWS.H already included.刚开始起步就遇到这么难的问题,的确是难住了我们的脚步。在网上搜了下,有很多网友都写了自己的博客,很多朋友也不是很清楚.我在这里进行记录,把这个问题
#import "c:\program files\common files\system\ado\msado15.dll" no_namespace rename("EOF","adoEOF") rename("BOF","adoBOF")这句话是要添加MFC对ado的支持. WINDOWS.H already included.是因为import这句话的位置出现了问题。StdAfx.h中,把上述的import写在最后一行上。也可以把这个msado15.dll复制到工程目录下。如下,这样问题就解决了
//#import "msado15.dll" no_namespace rename("EOF","adoEOF") //这句话应该写在最后面,要不然会出错的
阅读全文
摘要:在VC中编译发生如下错误的解决办法:
LINK : fatal error LNK1104: cannot open file "mfc42ud.lib"
缺少支持Unicode的文件;MFC安装的时候,默认是不安装支持Unicode的相关文件的
在vc 的安装盘上有,在vc98\MFC\Lib\下, 还需要dll,在vc98\Debug下。
下载地址(右击->目标另存为):
http://download.csdn.net/source/2308136
把lib放到vc的mfc\lib下,dll放到windows\system32下。
(转自:http://coosign.bokee.com/5547319.html)
阅读全文