﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>C++博客-    Update 牌...@ Blog-随笔分类-数据库</title><link>http://www.cppblog.com/Lee7/category/7343.html</link><description>  当华美的叶片落尽，生命的脉络才历历可见。 －－ 聂鲁达    
</description><language>zh-cn</language><lastBuildDate>Fri, 28 Nov 2008 08:40:11 GMT</lastBuildDate><pubDate>Fri, 28 Nov 2008 08:40:11 GMT</pubDate><ttl>60</ttl><item><title> ADO客户数据库编程</title><link>http://www.cppblog.com/Lee7/archive/2008/11/27/68000.html</link><dc:creator>isabc</dc:creator><author>isabc</author><pubDate>Thu, 27 Nov 2008 09:25:00 GMT</pubDate><guid>http://www.cppblog.com/Lee7/archive/2008/11/27/68000.html</guid><wfw:comment>http://www.cppblog.com/Lee7/comments/68000.html</wfw:comment><comments>http://www.cppblog.com/Lee7/archive/2008/11/27/68000.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/Lee7/comments/commentRss/68000.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/Lee7/services/trackbacks/68000.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: ADO，即ActiveX Data Objects，是一种特殊的OLE DB客户程序，它允许访问程序在Visual C++、Visual Basic、VBscript、Java等编程语言中访问。虽然ADO的巨大优势在于Visual Basic和VBscript的使用，但是在某些特殊的情况下，ADO在Visual C++中的访问是无法避免的。正是由于ADO本身是一种OLE DB客户程序，所以在数据库应用程序里使用ADO变得更加容易。&nbsp;&nbsp;<a href='http://www.cppblog.com/Lee7/archive/2008/11/27/68000.html'>阅读全文</a><img src ="http://www.cppblog.com/Lee7/aggbug/68000.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/Lee7/" target="_blank">isabc</a> 2008-11-27 17:25 <a href="http://www.cppblog.com/Lee7/archive/2008/11/27/68000.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>OLE DB客户数据库编程</title><link>http://www.cppblog.com/Lee7/archive/2008/11/27/67997.html</link><dc:creator>isabc</dc:creator><author>isabc</author><pubDate>Thu, 27 Nov 2008 08:34:00 GMT</pubDate><guid>http://www.cppblog.com/Lee7/archive/2008/11/27/67997.html</guid><wfw:comment>http://www.cppblog.com/Lee7/comments/67997.html</wfw:comment><comments>http://www.cppblog.com/Lee7/archive/2008/11/27/67997.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/Lee7/comments/commentRss/67997.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/Lee7/services/trackbacks/67997.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: OLE DB是一种非常具有发展潜力的数据库访问技术，它首先基于COM技术，以COM规范为基础建立数据库访问接口，成为介于数据库应用和数据源之间的一种通用数据访问标准；其次，OLE DB能够访问的数据源不再受到限制，OLE DB通过OLE DB服务器将数据源透明化。从6.0版本开始，Visual C++提供了对OLE DB的全面支持。&nbsp;&nbsp;<a href='http://www.cppblog.com/Lee7/archive/2008/11/27/67997.html'>阅读全文</a><img src ="http://www.cppblog.com/Lee7/aggbug/67997.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/Lee7/" target="_blank">isabc</a> 2008-11-27 16:34 <a href="http://www.cppblog.com/Lee7/archive/2008/11/27/67997.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>SQL Server存储过程入门案例详解[转]</title><link>http://www.cppblog.com/Lee7/archive/2008/10/28/65349.html</link><dc:creator>isabc</dc:creator><author>isabc</author><pubDate>Tue, 28 Oct 2008 09:06:00 GMT</pubDate><guid>http://www.cppblog.com/Lee7/archive/2008/10/28/65349.html</guid><wfw:comment>http://www.cppblog.com/Lee7/comments/65349.html</wfw:comment><comments>http://www.cppblog.com/Lee7/archive/2008/10/28/65349.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/Lee7/comments/commentRss/65349.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/Lee7/services/trackbacks/65349.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: 存储过程是存储于数据库中的一组T-SQL语句。有了存储过程之后，与数据库的交互就没有必要在程序中写一堆的SQL语句，而只需用一条语句调用适当的存储过程来完成就可以了。另外，由于代码是存储在数据库中，我们也可以在不同的应用程序或查询窗口中不断的重复利用那些代码。下面将讲述一些简单的例子，它们将说明如何构造和使用存储过程。&nbsp;&nbsp;<a href='http://www.cppblog.com/Lee7/archive/2008/10/28/65349.html'>阅读全文</a><img src ="http://www.cppblog.com/Lee7/aggbug/65349.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/Lee7/" target="_blank">isabc</a> 2008-10-28 17:06 <a href="http://www.cppblog.com/Lee7/archive/2008/10/28/65349.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>SQL触发器语法参考 </title><link>http://www.cppblog.com/Lee7/archive/2008/07/21/56766.html</link><dc:creator>isabc</dc:creator><author>isabc</author><pubDate>Mon, 21 Jul 2008 07:38:00 GMT</pubDate><guid>http://www.cppblog.com/Lee7/archive/2008/07/21/56766.html</guid><wfw:comment>http://www.cppblog.com/Lee7/comments/56766.html</wfw:comment><comments>http://www.cppblog.com/Lee7/archive/2008/07/21/56766.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/Lee7/comments/commentRss/56766.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/Lee7/services/trackbacks/56766.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: 内容提要：<br>创建触发器，触发器是一种特殊的存储过程，在用户试图对指定的表执行指定的数据修改语句时自动执行。Microsoft®SQLServer™允许为... &nbsp;&nbsp;<a href='http://www.cppblog.com/Lee7/archive/2008/07/21/56766.html'>阅读全文</a><img src ="http://www.cppblog.com/Lee7/aggbug/56766.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/Lee7/" target="_blank">isabc</a> 2008-07-21 15:38 <a href="http://www.cppblog.com/Lee7/archive/2008/07/21/56766.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>VC执行存储过程</title><link>http://www.cppblog.com/Lee7/archive/2008/07/03/55193.html</link><dc:creator>isabc</dc:creator><author>isabc</author><pubDate>Thu, 03 Jul 2008 02:42:00 GMT</pubDate><guid>http://www.cppblog.com/Lee7/archive/2008/07/03/55193.html</guid><wfw:comment>http://www.cppblog.com/Lee7/comments/55193.html</wfw:comment><comments>http://www.cppblog.com/Lee7/archive/2008/07/03/55193.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/Lee7/comments/commentRss/55193.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/Lee7/services/trackbacks/55193.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: 最近由于工作之需，要利用VC进行一些高级的数据库操作，如执行存储过程等。遍寻网络资源发现好使的不多（经常#30XX错误，大部分应该是COM的VARIANT数据类型所致，其实有个讨巧的方法，请看下文），在自己的实验下小有所得。记下学习笔记以备参考：&nbsp;&nbsp;<a href='http://www.cppblog.com/Lee7/archive/2008/07/03/55193.html'>阅读全文</a><img src ="http://www.cppblog.com/Lee7/aggbug/55193.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/Lee7/" target="_blank">isabc</a> 2008-07-03 10:42 <a href="http://www.cppblog.com/Lee7/archive/2008/07/03/55193.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>VC＋ADO存取SQL SERVER</title><link>http://www.cppblog.com/Lee7/archive/2008/07/02/55149.html</link><dc:creator>isabc</dc:creator><author>isabc</author><pubDate>Wed, 02 Jul 2008 08:04:00 GMT</pubDate><guid>http://www.cppblog.com/Lee7/archive/2008/07/02/55149.html</guid><wfw:comment>http://www.cppblog.com/Lee7/comments/55149.html</wfw:comment><comments>http://www.cppblog.com/Lee7/archive/2008/07/02/55149.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/Lee7/comments/commentRss/55149.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/Lee7/services/trackbacks/55149.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: 下面的代码是这样生成的<br>1)先生成一个MFC 对话框工程(名字叫Test)，并在stdafx.h加入下面一行，(注意路径)<br>#import "c:\program files\common files\system\ado\msado15.dll" no_namespace rename("EOF","adoEOF") <br>2)再在Test.h增加下面几个变量(protected)<br>_ConnectionPtr m_pConnection;//connection object's pointer <br>_CommandPtr m_pCommand; //command object's pointer<br>_ParameterPtr m_pParameter; //Parameter object's pointer<br>_RecordsetPtr m_pRecordset;<br>3)再修改Test.cpp中的InitInstance()&nbsp;&nbsp;<a href='http://www.cppblog.com/Lee7/archive/2008/07/02/55149.html'>阅读全文</a><img src ="http://www.cppblog.com/Lee7/aggbug/55149.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/Lee7/" target="_blank">isabc</a> 2008-07-02 16:04 <a href="http://www.cppblog.com/Lee7/archive/2008/07/02/55149.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>VC＋ADO存取SQL SERVER</title><link>http://www.cppblog.com/Lee7/archive/2008/07/02/55150.html</link><dc:creator>isabc</dc:creator><author>isabc</author><pubDate>Wed, 02 Jul 2008 08:04:00 GMT</pubDate><guid>http://www.cppblog.com/Lee7/archive/2008/07/02/55150.html</guid><wfw:comment>http://www.cppblog.com/Lee7/comments/55150.html</wfw:comment><comments>http://www.cppblog.com/Lee7/archive/2008/07/02/55150.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/Lee7/comments/commentRss/55150.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/Lee7/services/trackbacks/55150.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: 下面的代码是这样生成的<br>1)先生成一个MFC 对话框工程(名字叫Test)，并在stdafx.h加入下面一行，(注意路径)<br>#import "c:\program files\common files\system\ado\msado15.dll" no_namespace rename("EOF","adoEOF") <br>2)再在Test.h增加下面几个变量(protected)<br>_ConnectionPtr m_pConnection;//connection object's pointer <br>_CommandPtr m_pCommand; //command object's pointer<br>_ParameterPtr m_pParameter; //Parameter object's pointer<br>_RecordsetPtr m_pRecordset;<br>3)再修改Test.cpp中的InitInstance()&nbsp;&nbsp;<a href='http://www.cppblog.com/Lee7/archive/2008/07/02/55150.html'>阅读全文</a><img src ="http://www.cppblog.com/Lee7/aggbug/55150.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/Lee7/" target="_blank">isabc</a> 2008-07-02 16:04 <a href="http://www.cppblog.com/Lee7/archive/2008/07/02/55150.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>SQL Server的Inner Join及Outer Join</title><link>http://www.cppblog.com/Lee7/archive/2008/06/19/53970.html</link><dc:creator>isabc</dc:creator><author>isabc</author><pubDate>Thu, 19 Jun 2008 02:03:00 GMT</pubDate><guid>http://www.cppblog.com/Lee7/archive/2008/06/19/53970.html</guid><wfw:comment>http://www.cppblog.com/Lee7/comments/53970.html</wfw:comment><comments>http://www.cppblog.com/Lee7/archive/2008/06/19/53970.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/Lee7/comments/commentRss/53970.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/Lee7/services/trackbacks/53970.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: 　在一个正规化的数据库环境中, 我们常会碰到这款情形: 所需的资料并不是放在同一个资料表中, 在这个时候, 你就要用到 Join<br><br>　　当然 Join 如何将不同的数据库的资料结合, 还要看你如何使用它, 一共有四种不同的 Join 的方式, 在这篇文章中我们将为你介绍 Inner Join 及 Outer Join 以及其应用<br>&nbsp;&nbsp;<a href='http://www.cppblog.com/Lee7/archive/2008/06/19/53970.html'>阅读全文</a><img src ="http://www.cppblog.com/Lee7/aggbug/53970.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/Lee7/" target="_blank">isabc</a> 2008-06-19 10:03 <a href="http://www.cppblog.com/Lee7/archive/2008/06/19/53970.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>SQLSERVER存储过程基础 </title><link>http://www.cppblog.com/Lee7/archive/2008/06/19/53962.html</link><dc:creator>isabc</dc:creator><author>isabc</author><pubDate>Thu, 19 Jun 2008 01:14:00 GMT</pubDate><guid>http://www.cppblog.com/Lee7/archive/2008/06/19/53962.html</guid><wfw:comment>http://www.cppblog.com/Lee7/comments/53962.html</wfw:comment><comments>http://www.cppblog.com/Lee7/archive/2008/06/19/53962.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/Lee7/comments/commentRss/53962.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/Lee7/services/trackbacks/53962.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: 1.声明变量<br>2.赋值语句 <br>3.条件判断(IF...ELSE) <br>4.多分支判断(case...when...then...else...end）<br>5.循环(while) <br>6.动态定义游标 <br>7.遍历游标<br>8.获得游标行数<br>9.事务处理<br>10.字符串连接<br>11.创建临时表存储外部数据表<br>12.存储过程的调用及返回值<br>13.Update语句常见错误总结 <br>14.Insert语句常见语法错误总结 &nbsp;&nbsp;<a href='http://www.cppblog.com/Lee7/archive/2008/06/19/53962.html'>阅读全文</a><img src ="http://www.cppblog.com/Lee7/aggbug/53962.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/Lee7/" target="_blank">isabc</a> 2008-06-19 09:14 <a href="http://www.cppblog.com/Lee7/archive/2008/06/19/53962.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>SQL Server中如何写存储过程 </title><link>http://www.cppblog.com/Lee7/archive/2008/06/19/53961.html</link><dc:creator>isabc</dc:creator><author>isabc</author><pubDate>Thu, 19 Jun 2008 00:47:00 GMT</pubDate><guid>http://www.cppblog.com/Lee7/archive/2008/06/19/53961.html</guid><wfw:comment>http://www.cppblog.com/Lee7/comments/53961.html</wfw:comment><comments>http://www.cppblog.com/Lee7/archive/2008/06/19/53961.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/Lee7/comments/commentRss/53961.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/Lee7/services/trackbacks/53961.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: 1、设计存储过程 <br>几乎任何可写成批处理的 Transact-SQL 代码都可用于创建存储过程。<br>&nbsp;&nbsp;<a href='http://www.cppblog.com/Lee7/archive/2008/06/19/53961.html'>阅读全文</a><img src ="http://www.cppblog.com/Lee7/aggbug/53961.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/Lee7/" target="_blank">isabc</a> 2008-06-19 08:47 <a href="http://www.cppblog.com/Lee7/archive/2008/06/19/53961.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>vc通过ADO连接sql server 2000的核心代码</title><link>http://www.cppblog.com/Lee7/archive/2008/06/18/53823.html</link><dc:creator>isabc</dc:creator><author>isabc</author><pubDate>Wed, 18 Jun 2008 02:43:00 GMT</pubDate><guid>http://www.cppblog.com/Lee7/archive/2008/06/18/53823.html</guid><wfw:comment>http://www.cppblog.com/Lee7/comments/53823.html</wfw:comment><comments>http://www.cppblog.com/Lee7/archive/2008/06/18/53823.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/Lee7/comments/commentRss/53823.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/Lee7/services/trackbacks/53823.html</trackback:ping><description><![CDATA[<div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top><span style="COLOR: #000000">建立一个mfc对话框工程，一切都默认然后完成，接下照我的方法做吧，一定可以的！<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top><br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top>注：</span><span style="COLOR: #000000">*****</span><span style="COLOR: #000000">代表你所建立的工程名称<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top><br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top>先在stdafx.h中导入#import&nbsp;</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">c:\program&nbsp;files\common&nbsp;files\system\ado\msado15.dll</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">&nbsp;no_namespace&nbsp;rename(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">EOF</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">,</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">adoEOF</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">)<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top>加入头文件<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top>#include&nbsp;</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">icrsint.h</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000"><br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top>#include&nbsp;</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">adoid.h</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000"><br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top>然后进行下面的书写,必须要初始化COM&nbsp;即::CoInitialize(NULL);&nbsp;<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top>还要加入成员变量<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top>_RecordsetPtr&nbsp;pRec;<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top>_ConnectionPtr&nbsp;pCon;<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top><br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">==========&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;============</span><span style="COLOR: #008000">//<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #000000"><br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top>BOOL&nbsp;C</span><span style="COLOR: #000000">*****</span><span style="COLOR: #000000">App::InitInstance()<br><img id=Codehighlighter1_397_912_Open_Image onclick="this.style.display='none'; Codehighlighter1_397_912_Open_Text.style.display='none'; Codehighlighter1_397_912_Closed_Image.style.display='inline'; Codehighlighter1_397_912_Closed_Text.style.display='inline';" src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedBlockStart.gif" align=top><img id=Codehighlighter1_397_912_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_397_912_Closed_Text.style.display='none'; Codehighlighter1_397_912_Open_Image.style.display='inline'; Codehighlighter1_397_912_Open_Text.style.display='inline';" src="http://www.cppblog.com/Images/OutliningIndicators/ContractedBlock.gif" align=top></span><span id=Codehighlighter1_397_912_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><img src="http://www.cppblog.com/Images/dot.gif"></span><span id=Codehighlighter1_397_912_Open_Text><span style="COLOR: #000000">{<br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top></span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000">&nbsp;(</span><span style="COLOR: #000000">!</span><span style="COLOR: #000000">AfxSocketInit())<br><img id=Codehighlighter1_421_485_Open_Image onclick="this.style.display='none'; Codehighlighter1_421_485_Open_Text.style.display='none'; Codehighlighter1_421_485_Closed_Image.style.display='inline'; Codehighlighter1_421_485_Closed_Text.style.display='inline';" src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><img id=Codehighlighter1_421_485_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_421_485_Closed_Text.style.display='none'; Codehighlighter1_421_485_Open_Image.style.display='inline'; Codehighlighter1_421_485_Open_Text.style.display='inline';" src="http://www.cppblog.com/Images/OutliningIndicators/ContractedSubBlock.gif" align=top></span><span id=Codehighlighter1_421_485_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><img src="http://www.cppblog.com/Images/dot.gif"></span><span id=Codehighlighter1_421_485_Open_Text><span style="COLOR: #000000">{<br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;AfxMessageBox(IDP_SOCKETS_INIT_FAILED);<br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">return</span><span style="COLOR: #000000">&nbsp;FALSE;<br><img src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top>}</span></span><span style="COLOR: #000000"><br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top><br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>AfxEnableControlContainer();<br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;<br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top><br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>CString&nbsp;str;<br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>::CoInitialize(NULL);&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">初始化com&nbsp;必须为NULL</span><span style="COLOR: #008000"><br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top></span><span style="COLOR: #000000">str.Format(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">Provider=sqloledb;Network&nbsp;Library=DBMSSOCN;Initial&nbsp;Catalog=Test;User&nbsp;ID=sa;Password=1234;Data&nbsp;Source=192.168.0.20,1433</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">);<br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top><br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>pCon.CreateInstance(__uuidof(Connection));<br><img id=Codehighlighter1_759_812_Open_Image onclick="this.style.display='none'; Codehighlighter1_759_812_Open_Text.style.display='none'; Codehighlighter1_759_812_Closed_Image.style.display='inline'; Codehighlighter1_759_812_Closed_Text.style.display='inline';" src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><img id=Codehighlighter1_759_812_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_759_812_Closed_Text.style.display='none'; Codehighlighter1_759_812_Open_Image.style.display='inline'; Codehighlighter1_759_812_Open_Text.style.display='inline';" src="http://www.cppblog.com/Images/OutliningIndicators/ContractedSubBlock.gif" align=top></span><span style="COLOR: #0000ff">try</span><span id=Codehighlighter1_759_812_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><img src="http://www.cppblog.com/Images/dot.gif"></span><span id=Codehighlighter1_759_812_Open_Text><span style="COLOR: #000000">{<br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;pCon</span><span style="COLOR: #000000">-&gt;</span><span style="COLOR: #000000">Open(_bstr_t(str),</span><span style="COLOR: #000000">""</span><span style="COLOR: #000000">,</span><span style="COLOR: #000000">""</span><span style="COLOR: #000000">,adModeUnknown);<br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top><br><img src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top>}</span></span><span style="COLOR: #000000"><br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top></span><span style="COLOR: #0000ff">catch</span><span style="COLOR: #000000">(_com_error&nbsp;e)<br><img id=Codehighlighter1_834_910_Open_Image onclick="this.style.display='none'; Codehighlighter1_834_910_Open_Text.style.display='none'; Codehighlighter1_834_910_Closed_Image.style.display='inline'; Codehighlighter1_834_910_Closed_Text.style.display='inline';" src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><img id=Codehighlighter1_834_910_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_834_910_Closed_Text.style.display='none'; Codehighlighter1_834_910_Open_Image.style.display='inline'; Codehighlighter1_834_910_Open_Text.style.display='inline';" src="http://www.cppblog.com/Images/OutliningIndicators/ContractedSubBlock.gif" align=top></span><span id=Codehighlighter1_834_910_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><img src="http://www.cppblog.com/Images/dot.gif"></span><span id=Codehighlighter1_834_910_Open_Text><span style="COLOR: #000000">{<br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;MessageBox(NULL,</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">连接数据库失败！</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">,</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">警告</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">,MB_OK</span><span style="COLOR: #000000">|</span><span style="COLOR: #000000">MB_ICONHAND);<br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">return</span><span style="COLOR: #000000">&nbsp;FALSE;<br><img src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top>}</span></span><span style="COLOR: #000000"><br><img src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedBlockEnd.gif" align=top>}</span></span><span style="COLOR: #000000"><br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top><br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">==========&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;============</span><span style="COLOR: #008000">//<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #000000">在C</span><span style="COLOR: #000000">****</span><span style="COLOR: #000000">App中添加执行sql语句的方法<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #0000ff">bool</span><span style="COLOR: #000000">&nbsp;C</span><span style="COLOR: #000000">*****</span><span style="COLOR: #000000">App::OpenSQL(CString&nbsp;</span><span style="COLOR: #000000">&amp;</span><span style="COLOR: #000000">strRec)<br><img id=Codehighlighter1_1025_1357_Open_Image onclick="this.style.display='none'; Codehighlighter1_1025_1357_Open_Text.style.display='none'; Codehighlighter1_1025_1357_Closed_Image.style.display='inline'; Codehighlighter1_1025_1357_Closed_Text.style.display='inline';" src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedBlockStart.gif" align=top><img id=Codehighlighter1_1025_1357_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_1025_1357_Closed_Text.style.display='none'; Codehighlighter1_1025_1357_Open_Image.style.display='inline'; Codehighlighter1_1025_1357_Open_Text.style.display='inline';" src="http://www.cppblog.com/Images/OutliningIndicators/ContractedBlock.gif" align=top></span><span id=Codehighlighter1_1025_1357_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><img src="http://www.cppblog.com/Images/dot.gif"></span><span id=Codehighlighter1_1025_1357_Open_Text><span style="COLOR: #000000">{<br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>pRec.CreateInstance(__uuidof(Recordset));<br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top><br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top></span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000">&nbsp;(&nbsp;pRec</span><span style="COLOR: #000000">-&gt;</span><span style="COLOR: #000000">State&nbsp;)</span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">&nbsp;如果记录集打开的话，把它关了</span><span style="COLOR: #008000"><br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top></span><span style="COLOR: #000000">&nbsp;&nbsp;&nbsp;&nbsp;pRec</span><span style="COLOR: #000000">-&gt;</span><span style="COLOR: #000000">Close();<br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top><br><img id=Codehighlighter1_1129_1259_Open_Image onclick="this.style.display='none'; Codehighlighter1_1129_1259_Open_Text.style.display='none'; Codehighlighter1_1129_1259_Closed_Image.style.display='inline'; Codehighlighter1_1129_1259_Closed_Text.style.display='inline';" src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><img id=Codehighlighter1_1129_1259_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_1129_1259_Closed_Text.style.display='none'; Codehighlighter1_1129_1259_Open_Image.style.display='inline'; Codehighlighter1_1129_1259_Open_Text.style.display='inline';" src="http://www.cppblog.com/Images/OutliningIndicators/ContractedSubBlock.gif" align=top></span><span style="COLOR: #0000ff">try</span><span id=Codehighlighter1_1129_1259_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><img src="http://www.cppblog.com/Images/dot.gif"></span><span id=Codehighlighter1_1129_1259_Open_Text><span style="COLOR: #000000">{</span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">&nbsp;正常的SQL语句</span><span style="COLOR: #008000"><br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top></span><span style="COLOR: #000000">&nbsp;&nbsp;&nbsp;&nbsp;pRec</span><span style="COLOR: #000000">-&gt;</span><span style="COLOR: #000000">Open(_variant_t(strRec),pCon.GetInterfacePtr(),adOpenDynamic,adLockOptimistic,adCmdText);<br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">return</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #0000ff">true</span><span style="COLOR: #000000">;<br><img src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top>}</span></span><span style="COLOR: #000000"><br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top></span><span style="COLOR: #0000ff">catch</span><span style="COLOR: #000000">(_com_error&nbsp;e)<br><img id=Codehighlighter1_1281_1355_Open_Image onclick="this.style.display='none'; Codehighlighter1_1281_1355_Open_Text.style.display='none'; Codehighlighter1_1281_1355_Closed_Image.style.display='inline'; Codehighlighter1_1281_1355_Closed_Text.style.display='inline';" src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><img id=Codehighlighter1_1281_1355_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_1281_1355_Closed_Text.style.display='none'; Codehighlighter1_1281_1355_Open_Image.style.display='inline'; Codehighlighter1_1281_1355_Open_Text.style.display='inline';" src="http://www.cppblog.com/Images/OutliningIndicators/ContractedSubBlock.gif" align=top></span><span id=Codehighlighter1_1281_1355_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><img src="http://www.cppblog.com/Images/dot.gif"></span><span id=Codehighlighter1_1281_1355_Open_Text><span style="COLOR: #000000">{<br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;MessageBox(NULL,</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">连接表出错！</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">,</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">警告</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">,MB_OK</span><span style="COLOR: #000000">|</span><span style="COLOR: #000000">MB_ICONHAND);<br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">return</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #0000ff">false</span><span style="COLOR: #000000">;<br><img src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top>}</span></span><span style="COLOR: #000000"><br><img src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedBlockEnd.gif" align=top>}</span></span><span style="COLOR: #000000"><br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top>在退出的时候关闭数据库连接<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top><br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">==========&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;============</span><span style="COLOR: #008000">//</span><span style="COLOR: #008000"><br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">==========小狮子落落============</span><span style="COLOR: #008000">//<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000">&nbsp;C</span><span style="COLOR: #000000">****</span><span style="COLOR: #000000">App::ExitInstance()&nbsp;<br><img id=Codehighlighter1_1482_1649_Open_Image onclick="this.style.display='none'; Codehighlighter1_1482_1649_Open_Text.style.display='none'; Codehighlighter1_1482_1649_Closed_Image.style.display='inline'; Codehighlighter1_1482_1649_Closed_Text.style.display='inline';" src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedBlockStart.gif" align=top><img id=Codehighlighter1_1482_1649_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_1482_1649_Closed_Text.style.display='none'; Codehighlighter1_1482_1649_Open_Image.style.display='inline'; Codehighlighter1_1482_1649_Open_Text.style.display='inline';" src="http://www.cppblog.com/Images/OutliningIndicators/ContractedBlock.gif" align=top></span><span id=Codehighlighter1_1482_1649_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><img src="http://www.cppblog.com/Images/dot.gif"></span><span id=Codehighlighter1_1482_1649_Open_Text><span style="COLOR: #000000">{<br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top></span><span style="COLOR: #0000ff">try</span><span style="COLOR: #000000"><br><img id=Codehighlighter1_1488_1566_Open_Image onclick="this.style.display='none'; Codehighlighter1_1488_1566_Open_Text.style.display='none'; Codehighlighter1_1488_1566_Closed_Image.style.display='inline'; Codehighlighter1_1488_1566_Closed_Text.style.display='inline';" src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><img id=Codehighlighter1_1488_1566_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_1488_1566_Closed_Text.style.display='none'; Codehighlighter1_1488_1566_Open_Image.style.display='inline'; Codehighlighter1_1488_1566_Open_Text.style.display='inline';" src="http://www.cppblog.com/Images/OutliningIndicators/ContractedSubBlock.gif" align=top></span><span id=Codehighlighter1_1488_1566_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><img src="http://www.cppblog.com/Images/dot.gif"></span><span id=Codehighlighter1_1488_1566_Open_Text><span style="COLOR: #000000">{&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">&nbsp;关闭数据库</span><span style="COLOR: #008000"><br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top></span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000">&nbsp;(&nbsp;pCon</span><span style="COLOR: #000000">-&gt;</span><span style="COLOR: #000000">State&nbsp;)<br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;pCon</span><span style="COLOR: #000000">-&gt;</span><span style="COLOR: #000000">Close();<br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;pCon.Release();<br><img src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top>}</span></span><span style="COLOR: #000000"><br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top></span><span style="COLOR: #0000ff">catch</span><span style="COLOR: #000000">(_com_error&nbsp;e)<br><img id=Codehighlighter1_1588_1590_Open_Image onclick="this.style.display='none'; Codehighlighter1_1588_1590_Open_Text.style.display='none'; Codehighlighter1_1588_1590_Closed_Image.style.display='inline'; Codehighlighter1_1588_1590_Closed_Text.style.display='inline';" src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><img id=Codehighlighter1_1588_1590_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_1588_1590_Closed_Text.style.display='none'; Codehighlighter1_1588_1590_Open_Image.style.display='inline'; Codehighlighter1_1588_1590_Open_Text.style.display='inline';" src="http://www.cppblog.com/Images/OutliningIndicators/ContractedSubBlock.gif" align=top></span><span id=Codehighlighter1_1588_1590_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><img src="http://www.cppblog.com/Images/dot.gif"></span><span id=Codehighlighter1_1588_1590_Open_Text><span style="COLOR: #000000">{<br><img src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top>}</span></span><span style="COLOR: #000000"><br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>::CoUninitialize();&nbsp;&nbsp;&nbsp;&nbsp;<br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top><br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top></span><span style="COLOR: #0000ff">return</span><span style="COLOR: #000000">&nbsp;CWinApp::ExitInstance();<br><img src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedBlockEnd.gif" align=top>}</span></span><span style="COLOR: #000000"><br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top><br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top><br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top><br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top></span></div>
<img src ="http://www.cppblog.com/Lee7/aggbug/53823.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/Lee7/" target="_blank">isabc</a> 2008-06-18 10:43 <a href="http://www.cppblog.com/Lee7/archive/2008/06/18/53823.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>SQL SERVER 数据类型详解</title><link>http://www.cppblog.com/Lee7/archive/2008/06/18/53812.html</link><dc:creator>isabc</dc:creator><author>isabc</author><pubDate>Wed, 18 Jun 2008 02:00:00 GMT</pubDate><guid>http://www.cppblog.com/Lee7/archive/2008/06/18/53812.html</guid><wfw:comment>http://www.cppblog.com/Lee7/comments/53812.html</wfw:comment><comments>http://www.cppblog.com/Lee7/archive/2008/06/18/53812.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/Lee7/comments/commentRss/53812.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/Lee7/services/trackbacks/53812.html</trackback:ping><description><![CDATA[<table borderColor=#0099ff width="90%" align=center bgColor=#ffffff border=1>
    <tbody>
        <tr>
            <td width=106>
            <div align=center><strong>数据类型 </strong></div>
            </td>
            <td width=130>
            <div align=center><strong>类型 </strong></div>
            </td>
            <td vAlign=top>
            <div align=center><strong>描 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;述 </strong></div>
            </td>
        </tr>
        <tr>
            <td>
            <div align=center>bit </div>
            </td>
            <td>
            <div align=center>整型 </div>
            </td>
            <td>bit 数据类型是整型，其值只能是0、1或空值。这种数据类型用于存储只有两种可能值的数据，如Yes 或No、True 或Fa lse 、On 或Off </td>
        </tr>
        <tr>
            <td>
            <div align=center>int </div>
            </td>
            <td>
            <div align=center>整型 </div>
            </td>
            <td>int 数据类型可以存储从- 2<sup>31</sup>(-2147483648)到2<sup>31</sup> (2147483 647)之间的整数。存储到数据库的几乎所有数值型的数据都可以用这种数据类型。这种数据类型在数据库里占用4个字节 </td>
        </tr>
        <tr>
            <td>
            <div align=center>smallint </div>
            </td>
            <td>
            <div align=center>整型 </div>
            </td>
            <td>smallint 数据类型可以存储从- 2</span><sup>15</sup>(-32768)到2<sup>15</sup>(32767)之间的整数。这种数据类型对存储一些常限定在特定范围内的数值型数据非常有用。这种数据类型在数据库里占用2 字节空间 </td>
        </tr>
        <tr>
            <td>
            <div align=center>tinyint </div>
            </td>
            <td>
            <div align=center>整型 </div>
            </td>
            <td>tinyint 数据类型能存储从0到255 之间的整数。它在你只打算存储有限数目的数值时很有用。 这种数据类型在数据库中占用1 个字节 </td>
        </tr>
        <tr>
            <td>
            <div align=center>numeric</div>
            </td>
            <td>
            <div align=center>精确数值型 </div>
            </td>
            <td>numeric数据类型与decimal 型相同 </td>
        </tr>
        <tr>
            <td>
            <div align=center>decimal </div>
            </td>
            <td>
            <div align=center>精确数值型 </div>
            </td>
            <td>decimal 数据类型能用来存储从-10<sup>38</sup>-1到10<sup>38</sup>-1的固定精度和范围的数值型数据。使用这种数据类型时，必须指定范围和精度。 范围是小数点左右所能存储的数字的总位数。精度是小数点右边存储的数字的位数 </td>
        </tr>
        <tr>
            <td>
            <div align=center>money </div>
            </td>
            <td>
            <div align=center>货币型 </div>
            </td>
            <td>money 数据类型用来表示钱和货币值。这种数据类型能存储从-9220亿到9220 亿之间的数据，精确到货币单位的万分之一 </td>
        </tr>
        <tr>
            <td>
            <div align=center>smallmoney </div>
            </td>
            <td>
            <div align=center>货币型 </div>
            </td>
            <td>smallmoney 数据类型用来表示钱和货币值。这种数据类型能存储从-214748.3648 到214748.3647 之间的数据，精确到货币单位的万分之一 </td>
        </tr>
        <tr>
            <td>
            <div align=center>float </div>
            </td>
            <td>
            <div align=center>近似数值型 </div>
            </td>
            <td>float 数据类型是一种近似数值类型，供浮点数使用。说浮点数是近似的，是因为在其范围内不是所有的数都能精确表示。浮点数可以是从-1.79E+308到1.79E+308 之间的任意数 </td>
        </tr>
        <tr>
            <td>
            <div align=center>real </div>
            </td>
            <td>
            <div align=center>近似数值型 </div>
            </td>
            <td>real 数据类型像浮点数一样，是近似数值类型。它可以表示数值在-3.40E+38到3.40E+38之间的浮点数 </td>
        </tr>
        <tr>
            <td>
            <div align=center>datetime </div>
            </td>
            <td>
            <div align=center>日期时间型 </div>
            </td>
            <td>datetime数据类型用来表示日期和时间。这种数据类型存储从1753年1月1日到9999年12月3 1日间所有的日期和时间数据， 精确到三百分之一秒或3.33毫秒 </td>
        </tr>
        <tr>
            <td>
            <div align=center>Smalldatetime </div>
            </td>
            <td>
            <div align=center>日期时间型 </div>
            </td>
            <td>smalldatetime 数据类型用来表示从1900年1月1日到2079年6月6日间的日期和时间，精确到一分钟 </td>
        </tr>
        <tr>
            <td>
            <div align=center>cursor </div>
            </td>
            <td>
            <div align=center>特殊数据型 </div>
            </td>
            <td>cursor 数据类型是一种特殊的数据类型，它包含一个对游标的引用。这种数据类型用在存储过程中，而且创建表时不能用 </td>
        </tr>
        <tr>
            <td>
            <div align=center>timestamp </div>
            </td>
            <td>
            <div align=center>特殊数据型 </div>
            </td>
            <td>timestamp 数据类型是一种特殊的数据类型，用来创建一个数据库范围内的唯一数码。 一个表中只能有一个timestamp列。每次插入或修改一行时，timestamp列的值都会改变。尽管它的名字中有&#8220;time&#8221;， 但timestamp列不是人们可识别的日期。在一个数据库里，timestamp值是唯一的 </td>
        </tr>
        <tr>
            <td>
            <div align=center>Uniqueidentifier </div>
            </td>
            <td>
            <div align=center>特殊数据型 </div>
            </td>
            <td>Uniqueidentifier数据类型用来存储一个全局唯一标识符，即GUID。GUID确实是全局唯一的。这个数几乎没有机会在另一个系统中被重建。可以使用NEWID 函数或转换一个字符串为唯一标识符来初始化具有唯一标识符的列 </td>
        </tr>
        <tr>
            <td>
            <div align=center>char </div>
            </td>
            <td>
            <div align=center>字符型 </div>
            </td>
            <td>char数据类型用来存储指定长度的定长非统一编码型的数据。当定义一列为此类型时，你必须指定列长。当你总能知道要存储的数据的长度时，此数据类型很有用。例如，当你按邮政编码加4个字符格式来存储数据时，你知道总要用到10个字符。此数据类型的列宽最大为8000 个字符 </td>
        </tr>
        <tr>
            <td>
            <div align=center>varchar </div>
            </td>
            <td>
            <div align=center>字符型 </div>
            </td>
            <td>varchar数据类型，同char类型一样，用来存储非统一编码型字符数据。与char 型不一样，此数据类型为变长。当定义一列为该数据类型时，你要指定该列的最大长度。 它与char数据类型最大的区别是，存储的长度不是列长，而是数据的长度 </td>
        </tr>
        <tr>
            <td>
            <div align=center>text </div>
            </td>
            <td>
            <div align=center>字符型 </div>
            </td>
            <td>text 数据类型用来存储大量的非统一编码型字符数据。这种数据类型最多可以有2<sup>31</sup>-1或20亿个字符 </td>
        </tr>
        <tr>
            <td>
            <div align=center>nchar </div>
            </td>
            <td>
            <div align=center>统一编码字符型 </div>
            </td>
            <td>nchar 数据类型用来存储定长统一编码字符型数据。统一编码用双字节结构来存储每个字符，而不是用单字节(普通文本中的情况)。它允许大量的扩展字符。此数据类型能存储4000种字符，使用的字节空间上增加了一倍 </td>
        </tr>
        <tr>
            <td>
            <div align=center>nvarchar </div>
            </td>
            <td>
            <div align=center>统一编码字符型 </div>
            </td>
            <td>nvarchar 数据类型用作变长的统一编码字符型数据。此数据类型能存储4000种字符，使用的字节空间增加了一倍 </td>
        </tr>
        <tr>
            <td>
            <div align=center>ntext </div>
            </td>
            <td>
            <div align=center>统一编码字符型 </div>
            </td>
            <td>ntext 数据类型用来存储大量的统一编码字符型数据。这种数据类型能存储2<sup>30</sup> -1或将近10亿个字符，且使用的字节空间增加了一倍 </td>
        </tr>
        <tr>
            <td>
            <div align=center>binary </div>
            </td>
            <td>
            <div align=center>二进制数据类型 </div>
            </td>
            <td>binary数据类型用来存储可达8000 字节长的定长的二进制数据。当输入表的内容接近相同的长度时，你应该使用这种数据类型 </td>
        </tr>
        <tr>
            <td>
            <div align=center>varbinary </div>
            </td>
            <td>
            <div align=center>二进制数据类型 </div>
            </td>
            <td>varbinary 数据类型用来存储可达8000 字节长的变长的二进制数据。当输入表的内容大小可变时，你应该使用这种数据类型 </td>
        </tr>
        <tr>
            <td>
            <div align=center>image </div>
            </td>
            <td>
            <div align=center>二进制数据类型 </div>
            </td>
            <td>image 数据类型用来存储变长的二进制数据，最大可达2<sup>31</sup>-1或大约20亿字节 </td>
        </tr>
    </tbody>
</table>
<script event=onload for=window type=text/javascript>ImgLoad(document.getElementById("BodyLabel"));</script>
<img src ="http://www.cppblog.com/Lee7/aggbug/53812.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/Lee7/" target="_blank">isabc</a> 2008-06-18 10:00 <a href="http://www.cppblog.com/Lee7/archive/2008/06/18/53812.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>VC中使用ADO调用存储过程实现方法</title><link>http://www.cppblog.com/Lee7/archive/2008/06/17/53775.html</link><dc:creator>isabc</dc:creator><author>isabc</author><pubDate>Tue, 17 Jun 2008 15:39:00 GMT</pubDate><guid>http://www.cppblog.com/Lee7/archive/2008/06/17/53775.html</guid><wfw:comment>http://www.cppblog.com/Lee7/comments/53775.html</wfw:comment><comments>http://www.cppblog.com/Lee7/archive/2008/06/17/53775.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/Lee7/comments/commentRss/53775.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/Lee7/services/trackbacks/53775.html</trackback:ping><description><![CDATA[<p>开发环境是VS2005&nbsp; ,数据库是SQL Sever 2000</p>
<p>1. 在进入正题之前，先讲点别的，如何在VC中连接Sybase数据库，</p>
<p>&nbsp;&nbsp; 连接字符窜为，</p>
<p>&nbsp; _bstr_t strCnn(\"Driver={Sybase System 11};Srvr=RRRRR;Uid=RRR_Mao_bb1;Pwd=user2\");</p>
<p>这里，RRRRR是数据库的名称，已经在Sybase-&gt;sdedit中设定好了</p>
<p>&nbsp;RRR_Mao_bb1 和 user2分别是用户名和密码</p>
<p>&nbsp;不过使用这种基于ODBC的连接使用一段时间以后，就出现问题了，出现了&#8220;Catastrophic failure&#8221;的错误，微软的解释是&nbsp; http://support.microsoft.com/kb/243349/en-us</p>
<p>&nbsp;</p>
<p>2. 为了使我们的调用存储过程的例子有更多的通用性，我建了有输入参数，有输出参数，有一个返回记录集，有一个返回值的存储过程，如下</p>
<p>&nbsp;&nbsp; <br>CREATE&nbsp; PROCEDURE sp_1&nbsp; (<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; @pin1&nbsp; int ,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; @pin2&nbsp; CHAR(10),<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; @pout1 int OUTPUT,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; @pout2 CHAR(10)&nbsp; OUTPUT<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; )<br>AS&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>BEGIN<br>&nbsp; declare&nbsp; @retval&nbsp; int<br>&nbsp; <br>&nbsp; select @pout1 = @pin1 + 100<br>&nbsp; <br>&nbsp; select @pout2 =&nbsp; left( ltrim(rtrim(@pin2)) + \'123\' , 10)<br>&nbsp; <br>&nbsp; select Num,Name,Date <br>&nbsp;&nbsp;&nbsp; from TABLE1<br>&nbsp;&nbsp;&nbsp; <br>&nbsp; select @retval =&nbsp; 1236<br>&nbsp; <br>&nbsp; return @retval<br>END</p>
<p>对于这个SP来说，他这些个参数是</p>
<p>@RETURN_VALUE(int ,返回值)&nbsp;&nbsp;</p>
<p>@pin1 ( int&nbsp; ,输入 )&nbsp;&nbsp; </p>
<p>@pin2 ( char(10)&nbsp; ,输入 )&nbsp;</p>
<p>@pout1 (int ,输入/输出)&nbsp;</p>
<p>@pout1 ( char(10)&nbsp; , 输入/输出)&nbsp;&nbsp; </p>
<p>@RETURN_VALUE是第0个参数，@pin1是第1个，依此类推 </p>
<p>以上信息可以在SQL 的查询分析器中看到，注意，<font color=#ff0000>这些参数的顺序很重要</font></p>
<p>&nbsp;</p>
<p>3.调用的前期准备</p>
<p>&nbsp; 这就不多说了，什么import 库阿，建立连接阿，什么的，不多说了，</p>
<p>&nbsp;这些在<u><font color=#810081>&nbsp;VC中使用ADO进行数据库开发的一些资料的整理</font></u> 中有了阐述</p>
<p>假定连接是pConn</p>
<p>注意，这里要把pConn设定成adUseClient型[Page]</p>
<p><font color=#ff0000>pConn-&gt;CursorLocation =adUseClient;</font></p>
<p>下面我要贴具体的代码了，为了精简所贴的代码，我把所有的捕获异常都没贴出来(try catch)</p>
<p>&nbsp;</p>
<p>4.使用Refresh的方法来调用</p>
<p>先定义一些变量</p>
<p>&nbsp;_CommandPtr&nbsp;&nbsp;&nbsp;&nbsp; pCmd = NULL;<br>&nbsp;_RecordsetPtr&nbsp;&nbsp; pRecordset = NULL;</p>
<p>初试化他们，</p>
<p>&nbsp;pCmd.CreateInstance(__uuidof(Command));<br>&nbsp; pRecordset.CreateInstance(_uuidof(Recordset));<br>&nbsp; pCmd-&gt;ActiveConnection = pConn;<br>&nbsp; pCmd-&gt;CommandType = adCmdStoredProc;<br>&nbsp; pCmd-&gt;CommandText=_bstr_t(_T(\"sp_1\"));&nbsp; //SP Name</p>
<p>然后给那些input参数赋值</p>
<p>&nbsp;pCmd-&gt;Parameters-&gt;Refresh();&nbsp;&nbsp; <br>&nbsp; <br>pCmd-&gt;Parameters-&gt;Item[_variant_t(_bstr_t(\"@pin1\") )]-&gt;Value=_variant_t(3);&nbsp;&nbsp; </p>
<p>&nbsp;pCmd-&gt;Parameters-&gt;Item[_variant_t(_bstr_t(\"@pin2\") )]-&gt;Value=_variant_t(\"DD\");&nbsp;&nbsp; </p>
<p>这个refresh一定要有，</p>
<p>调SP</p>
<p>pRecordset =&nbsp; pCmd-&gt;Execute(NULL,NULL,adCmdStoredProc);</p>
<p>int&nbsp;&nbsp; retVal = -1;<br>&nbsp;_variant_t&nbsp;&nbsp; VretVal ; </p>
<p>//GetRetVal <br>&nbsp; VretVal = pCmd-&gt;Parameters-&gt;GetItem(short(0))-&gt;Value;<br>&nbsp; <br>&nbsp; retVal = VretVal.lVal;<br>&nbsp;&nbsp; <br>&nbsp; Info.Format(_T(\"The Return Value is : %d\"),retVal);<br>&nbsp; MessageBox(Info);</p>
<p><br>&nbsp; //output1 <br>&nbsp; VretVal = pCmd-&gt;Parameters-&gt;GetItem(short(3))-&gt;Value; <br>&nbsp; retVal = VretVal.lVal;<br>&nbsp;&nbsp; <br>&nbsp; Info.Format(_T(\"The output1 Value is : %d\"),retVal);<br>&nbsp; MessageBox(Info);<br>&nbsp; </p>
<p>&nbsp; //@pout2 <br>&nbsp; VretVal = pCmd-&gt;Parameters-&gt;GetItem(short(4))-&gt;Value;<br>&nbsp; <br>&nbsp; Info= (LPCTSTR)_bstr_t(VretVal);<br>&nbsp; CString info1;<br>&nbsp; info1.Format(_T(\"The output2 Value is : %s\"),Info);<br>&nbsp; <br>&nbsp; MessageBox(info1);</p>
<p>&nbsp;//取记录集里面的内容</p>
<p><br>&nbsp; if (pRecordset-&gt;adoBOF &amp;&amp; pRecordset-&gt;adoEOF)<br>&nbsp; {<br>&nbsp;&nbsp; MessageBox(\"没有符合条件的记录存在!\",\"提示\");</p>
<p>&nbsp;&nbsp; if(pRecordset != NULL &amp;&amp; pRecordset-&gt;State)<br>&nbsp;&nbsp; {<br>&nbsp;&nbsp;&nbsp; pRecordset-&gt;Close();<br>&nbsp;&nbsp;&nbsp; pRecordset = NULL;&nbsp; </p>
}
<p>&#160;</p>
<p>&nbsp;&nbsp; pCmd.Detach();<br>&nbsp;&nbsp; return;<br>&nbsp; } <br>&nbsp; <br>&nbsp; pRecordset-&gt;MoveFirst();<br>&nbsp; <br>&nbsp; for(;!pRecordset-&gt;adoEOF;pRecordset-&gt;MoveNext())<br>&nbsp; {<br>&nbsp;&nbsp; VRectVal = pRecordset-&gt;GetCollect(_T(\"Name\"));<br>&nbsp;&nbsp; StrVal = (LPCTSTR)_bstr_t(VRectVal);<br>&nbsp;&nbsp; m_list.AddString(StrVal);<br>&nbsp; }<br>&nbsp; </p>
<p>&nbsp; if(pRecordset != NULL &amp;&amp; pRecordset-&gt;State)<br>&nbsp; {<br>&nbsp;&nbsp; pRecordset-&gt;Close();<br>&nbsp;&nbsp; pRecordset = NULL;&nbsp; [Page]<br>&nbsp; }</p>
<p>最后pCmd.Detach();</p>
<p>&nbsp;在这里，有一点要注意的是</p>
<p>VretVal = pCmd-&gt;Parameters-&gt;GetItem(short(4))-&gt;Value;<br>这里的4，就是哪个output参数的index，就是我在2中说的参数的顺序</p>
<p>这里使用了Refresh，这是一个很重要的函数，我将在下面介绍一下它，我要先贴出另一种，不使用Refresh的办法，</p>
<p>5 .使用非Refresh的方法来调用</p>
<p>先定义变量</p>
<p>_CommandPtr&nbsp;&nbsp;&nbsp;&nbsp; pCmd = NULL;<br>&nbsp;_RecordsetPtr&nbsp;&nbsp; pRecordset = NULL;</p>
<p><br>&nbsp;_ParameterPtr&nbsp;&nbsp; retParam = NULL;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; _ParameterPtr&nbsp;&nbsp; inParam1 = NULL;&nbsp; <br>&nbsp;_ParameterPtr&nbsp;&nbsp; inParam2 = NULL;&nbsp; <br>&nbsp;_ParameterPtr&nbsp;&nbsp; outParam1 = NULL; <br>&nbsp;_ParameterPtr&nbsp;&nbsp; outParam2 = NULL;&nbsp; </p>
<p>初试化</p>
<p><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; pCmd.CreateInstance(__uuidof(Command));<br>&nbsp; pRecordset.CreateInstance(_uuidof(Recordset));</p>
<p>retParam.CreateInstance(__uuidof(Parameter));</p>
<p>//其他的ParameterPtr&nbsp;&nbsp; 也初试化<br>&nbsp; pCmd-&gt;ActiveConnection = pConn;<br>&nbsp; pCmd-&gt;CommandType = adCmdStoredProc;<br>&nbsp;&nbsp; pCmd-&gt;CommandText=_bstr_t(_T(\"sp_1\"));&nbsp; //SP Name</p>
<p>&nbsp;retParam = pCmd -&gt;CreateParameter(_bstr_t(\"Return\"),<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; adInteger,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; adParamReturnValue,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sizeof(int));<br>&nbsp; pCmd-&gt;Parameters-&gt;Append(retParam); </p>
<p>&nbsp; <br>&nbsp; <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; inParam1&nbsp; = pCmd -&gt;CreateParameter(_bstr_t(\"InParam1\"),<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; adInteger,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; adParamInput,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sizeof(int));</p>
<p>&nbsp; inParam1-&gt;Value = _variant_t(3);</p>
<p>&nbsp; pCmd-&gt;Parameters-&gt;Append(inParam1); </p>
<p><br>&nbsp; inParam2&nbsp; = pCmd -&gt;CreateParameter(_bstr_t(\"InParam2\"),<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; adChar,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; adParamInput,[Page]<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 10);<br>&nbsp;<br>&nbsp; inParam2-&gt;Value = _variant_t(_T(\"DD1\"));</p>
<p>&nbsp; pCmd-&gt;Parameters-&gt;Append(inParam2); </p>
<p><br>&nbsp; outParam1 = pCmd -&gt;CreateParameter(_bstr_t(\"OutParam1\"),<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; adInteger,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; adParamOutput,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; sizeof(int));<br>&nbsp; pCmd-&gt;Parameters-&gt;Append(outParam1); </p>
<p><br>&nbsp; outParam2 = pCmd -&gt;CreateParameter(_bstr_t(\"OutParam2\"),<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; adChar,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; adParamOutput,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 10);<br>&nbsp; pCmd-&gt;Parameters-&gt;Append(outParam2); </p>
<p>&nbsp;</p>
<p>这里不用refresh的办法，是用Parameter来，这里要注意的是，这个add的顺序要和参数的index顺序要一致</p>
<p>下面就是调用了</p>
<p>pRecordset =&nbsp; pCmd-&gt;Execute(NULL,NULL,adCmdStoredProc);</p>
<p>然后取那些return值阿，output值阿什么的</p>
<p>这里有一个区别，就是用这种办法</p>
<p>可以有三种办法来取这些返回值和output参数</p>
<p>VretVal = pCmd-&gt;Parameters-&gt;GetItem(_bstr_t(\"Return\"))-&gt;Value;<br>VretVal = pCmd-&gt;Parameters-&gt;GetItem(short(0))-&gt;Value;<br>&nbsp;VretVal = retParam-&gt;Value;</p>
<p>都是一样的</p>
<p>6. 关于Refresh</p>
<p>关于这个函数，作用是</p>
<p>Command&nbsp;&nbsp; 对象去重新索取要操作的存储过程所有有关参数的信息，并且清空在refresh之前获取的参数信息。&nbsp;&nbsp; </p>
<p>所以一但调用它以后，就可以获取SP的那些信息，那些参数的信息，可以通过pCmd-&gt;Parameters-&gt;Item[_variant_t(_bstr_t(\"@pin1\") )]-&gt;Value=_variant_t(3);&nbsp;&nbsp; 这样的方式来设置参数</p>
<p>如果要使用Parameter的办法的话，就不要用refresh了，事实上，如果先把这些参数的值设置好了，如&nbsp; inParam2-&gt;Value = _variant_t(_T(\"DD1\"));，一旦refresh后，这些参数就没有意义了。</p>
<p>7.关于pConn-&gt;CursorLocation =adUseClient;</p>
<p>&nbsp;设置这个东西，如果不设置游标为adUseClient，那么我在取return和output参数的时候，必须在我把记录集关闭以后才能取，就是说，必须先取记录集，然后关闭它，最后再取return和output参数，如果我在关闭记录集之前就取return和output的值，那么就不能取到正确的值，设成adUseClient就ok了，</p>
<p>另外有一点就是，Execute 方法返回的游标继承该设置。Recordset 将自动从与之关联的连接中继承该设置。我把pConn设成adUseClient，那么最后，我的记录集也是adUseClient的了[Page]</p>
<img src ="http://www.cppblog.com/Lee7/aggbug/53775.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/Lee7/" target="_blank">isabc</a> 2008-06-17 23:39 <a href="http://www.cppblog.com/Lee7/archive/2008/06/17/53775.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>vc里如何调用存储过程</title><link>http://www.cppblog.com/Lee7/archive/2008/06/17/53772.html</link><dc:creator>isabc</dc:creator><author>isabc</author><pubDate>Tue, 17 Jun 2008 15:21:00 GMT</pubDate><guid>http://www.cppblog.com/Lee7/archive/2008/06/17/53772.html</guid><wfw:comment>http://www.cppblog.com/Lee7/comments/53772.html</wfw:comment><comments>http://www.cppblog.com/Lee7/archive/2008/06/17/53772.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.cppblog.com/Lee7/comments/commentRss/53772.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/Lee7/services/trackbacks/53772.html</trackback:ping><description><![CDATA[<div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top><span style="COLOR: #000000">_ConnectionPtr&nbsp;m_pConnection;<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top>_CommandPtr&nbsp;m_pCommand;<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">.cpp中在函数中执行<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">建立ado连接</span><span style="COLOR: #008000"><br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #000000">HRESULT&nbsp;hr;<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top>hr</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">m_pConnection.CreateInstance(__uuidof(Connection));<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #0000ff">try</span><span style="COLOR: #000000"><br><img id=Codehighlighter1_149_358_Open_Image onclick="this.style.display='none'; Codehighlighter1_149_358_Open_Text.style.display='none'; Codehighlighter1_149_358_Closed_Image.style.display='inline'; Codehighlighter1_149_358_Closed_Text.style.display='inline';" src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedBlockStart.gif" align=top><img id=Codehighlighter1_149_358_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_149_358_Closed_Text.style.display='none'; Codehighlighter1_149_358_Open_Image.style.display='inline'; Codehighlighter1_149_358_Open_Text.style.display='inline';" src="http://www.cppblog.com/Images/OutliningIndicators/ContractedBlock.gif" align=top></span><span id=Codehighlighter1_149_358_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><img src="http://www.cppblog.com/Images/dot.gif"></span><span id=Codehighlighter1_149_358_Open_Text><span style="COLOR: #000000">{<br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">if</span><span style="COLOR: #000000">(SUCCEEDED(hr))<br><img id=Codehighlighter1_171_356_Open_Image onclick="this.style.display='none'; Codehighlighter1_171_356_Open_Text.style.display='none'; Codehighlighter1_171_356_Closed_Image.style.display='inline'; Codehighlighter1_171_356_Closed_Text.style.display='inline';" src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif" align=top><img id=Codehighlighter1_171_356_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_171_356_Closed_Text.style.display='none'; Codehighlighter1_171_356_Open_Image.style.display='inline'; Codehighlighter1_171_356_Open_Text.style.display='inline';" src="http://www.cppblog.com/Images/OutliningIndicators/ContractedSubBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;</span><span id=Codehighlighter1_171_356_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><img src="http://www.cppblog.com/Images/dot.gif"></span><span id=Codehighlighter1_171_356_Open_Text><span style="COLOR: #000000">{<br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;hr</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">m_pConnection</span><span style="COLOR: #000000">-&gt;</span><span style="COLOR: #000000">Open(_bstr_t(L</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">Provider=SQLOLEDB.1;Persist&nbsp;Security&nbsp;Info=False;User&nbsp;ID=sa;Initial&nbsp;Catalog=Viper;Data&nbsp;Source=Viper</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">),_bstr_t&nbsp;(L</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">sa</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">),_bstr_t&nbsp;(L</span><span style="COLOR: #000000">""</span><span style="COLOR: #000000">),adModeUnknown);<br><img src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedSubBlockEnd.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;}</span></span><span style="COLOR: #000000"><br><img src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedBlockEnd.gif" align=top>}</span></span><span style="COLOR: #000000"><br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #0000ff">catch</span><span style="COLOR: #000000">(_com_error&nbsp;</span><span style="COLOR: #000000">&amp;</span><span style="COLOR: #000000">&nbsp;err)<br><img id=Codehighlighter1_384_543_Open_Image onclick="this.style.display='none'; Codehighlighter1_384_543_Open_Text.style.display='none'; Codehighlighter1_384_543_Closed_Image.style.display='inline'; Codehighlighter1_384_543_Closed_Text.style.display='inline';" src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedBlockStart.gif" align=top><img id=Codehighlighter1_384_543_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_384_543_Closed_Text.style.display='none'; Codehighlighter1_384_543_Open_Image.style.display='inline'; Codehighlighter1_384_543_Open_Text.style.display='inline';" src="http://www.cppblog.com/Images/OutliningIndicators/ContractedBlock.gif" align=top></span><span id=Codehighlighter1_384_543_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><img src="http://www.cppblog.com/Images/dot.gif"></span><span id=Codehighlighter1_384_543_Open_Text><span style="COLOR: #000000">{<br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;AfxMessageBox(err.Description(),MB_OK,</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">);<br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;AfxMessageBox(err.ErrorMessage(),MB_OK,</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">);<br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;AfxMessageBox(</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">无法连接SQL&nbsp;SERVER&nbsp;服务器，程序将退出。请检查网络设备</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">,MB_OK,</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">);<br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;exit(</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">);<br><img src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedBlockEnd.gif" align=top>}</span></span><span style="COLOR: #000000"><br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top><br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #008000">//</span><span style="COLOR: #008000">执行储存过程</span><span style="COLOR: #008000"><br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #000000">CString&nbsp;cvar1,cvar2;<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #0000ff">int</span><span style="COLOR: #000000">&nbsp;cvar3;<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top>cvar1</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">&#8221;ddd&#8221;;<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top>cvar2</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">&#8221;</span><span style="COLOR: #000000">"</span><span style="COLOR: #000000">;</span><span style="COLOR: #000000"><br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #000000">cvar3</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">0</span><span style="COLOR: #000000">;<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #0000ff">try</span><span style="COLOR: #000000"><br><img id=Codehighlighter1_623_1756_Open_Image onclick="this.style.display='none'; Codehighlighter1_623_1756_Open_Text.style.display='none'; Codehighlighter1_623_1756_Closed_Image.style.display='inline'; Codehighlighter1_623_1756_Closed_Text.style.display='inline';" src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedBlockStart.gif" align=top><img id=Codehighlighter1_623_1756_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_623_1756_Closed_Text.style.display='none'; Codehighlighter1_623_1756_Open_Image.style.display='inline'; Codehighlighter1_623_1756_Open_Text.style.display='inline';" src="http://www.cppblog.com/Images/OutliningIndicators/ContractedBlock.gif" align=top></span><span id=Codehighlighter1_623_1756_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><img src="http://www.cppblog.com/Images/dot.gif"></span><span id=Codehighlighter1_623_1756_Open_Text><span style="COLOR: #000000">{<br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;m_pCommand.CreateInstance(__uuidof(Command));<br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;m_pCommand</span><span style="COLOR: #000000">-&gt;</span><span style="COLOR: #000000">ActiveConnection</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">app</span><span style="COLOR: #000000">-&gt;</span><span style="COLOR: #000000">m_pConnection;<br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;m_pCommand</span><span style="COLOR: #000000">-&gt;</span><span style="COLOR: #000000">CommandType</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">adCmdStoredProc;<br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;m_pCommand</span><span style="COLOR: #000000">-&gt;</span><span style="COLOR: #000000">CommandText</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">_bstr_t(&#8221;pr_zs_dzdy&#8221;);<br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;<br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;_variant_t&nbsp;vvar1,vvar2,vvar3;<br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;vvar1</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">_variant_t(_bstr_t(cvar1));<br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;vvar2</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">_variant_t(_bstr_t(cvar2));<br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;vvar3</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">_variant_t(cvar3);<br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;_ParameterPtr&nbsp;mp_var1,mp_var2,mp_var3;<br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;mp_var1.CreateInstance(__uuidof(Parameter));<br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;mp_var2.CreateInstance(__uuidof(Parameter));<br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;mp_var3.CreateInstance(__uuidof(Parameter));<br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;<br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;mp_var1</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">m_pCommand</span><span style="COLOR: #000000">-&gt;</span><span style="COLOR: #000000">CreateParameter<br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(<br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;_bstr_t(&#8221;var1&#8243;),<br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;adVarChar,<br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;adParamInput,<br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #000000">3</span><span style="COLOR: #000000">,<br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;vvar1<br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;);<br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;m_pCommand</span><span style="COLOR: #000000">-&gt;</span><span style="COLOR: #000000">Parameters</span><span style="COLOR: #000000">-&gt;</span><span style="COLOR: #000000">Append(mp_var1);<br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;<br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;mp_var2</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">m_pCommand</span><span style="COLOR: #000000">-&gt;</span><span style="COLOR: #000000">CreateParameter<br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(<br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;_bstr_t(&#8221;var2&#8243;),<br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;adVarChar,<br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;adParamOutput,<br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #000000">3</span><span style="COLOR: #000000">,<br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;vvar2<br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;);<br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;m_pCommand</span><span style="COLOR: #000000">-&gt;</span><span style="COLOR: #000000">Parameters</span><span style="COLOR: #000000">-&gt;</span><span style="COLOR: #000000">Append(mp_var2);<br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;<br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;mp_var3</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">m_pCommand</span><span style="COLOR: #000000">-&gt;</span><span style="COLOR: #000000">CreateParameter<br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;(<br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;_bstr_t(&#8221;var3&#8243;),<br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;adIntger,<br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;adParamOutput,<br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #000000">9</span><span style="COLOR: #000000">,<br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;vvar3<br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;);<br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;m_pCommand</span><span style="COLOR: #000000">-&gt;</span><span style="COLOR: #000000">Parameters</span><span style="COLOR: #000000">-&gt;</span><span style="COLOR: #000000">Append(mp_var3);<br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;<br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;_variant_t&nbsp;vNull;<br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;vNull.vt</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">VT_ERROR;<br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;vNull.scode</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">DISP_E_PARAMNOTFOUND;<br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;m_pCommand</span><span style="COLOR: #000000">-&gt;</span><span style="COLOR: #000000">Execute(</span><span style="COLOR: #000000">&amp;</span><span style="COLOR: #000000">vNull,</span><span style="COLOR: #000000">&amp;</span><span style="COLOR: #000000">vNull,adCmdStoredProc);<br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;cvar2</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">mp_var2</span><span style="COLOR: #000000">-&gt;</span><span style="COLOR: #000000">Value.bstrVal;<br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;cvar3</span><span style="COLOR: #000000">=</span><span style="COLOR: #000000">mp_var3</span><span style="COLOR: #000000">-&gt;</span><span style="COLOR: #000000">Value;<br><img src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedBlockEnd.gif" align=top>}</span></span><span style="COLOR: #000000"><br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #0000ff">catch</span><span style="COLOR: #000000">(_com_error&nbsp;</span><span style="COLOR: #000000">&amp;</span><span style="COLOR: #000000">error)<br><img id=Codehighlighter1_1783_1872_Open_Image onclick="this.style.display='none'; Codehighlighter1_1783_1872_Open_Text.style.display='none'; Codehighlighter1_1783_1872_Closed_Image.style.display='inline'; Codehighlighter1_1783_1872_Closed_Text.style.display='inline';" src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedBlockStart.gif" align=top><img id=Codehighlighter1_1783_1872_Closed_Image style="DISPLAY: none" onclick="this.style.display='none'; Codehighlighter1_1783_1872_Closed_Text.style.display='none'; Codehighlighter1_1783_1872_Open_Image.style.display='inline'; Codehighlighter1_1783_1872_Open_Text.style.display='inline';" src="http://www.cppblog.com/Images/OutliningIndicators/ContractedBlock.gif" align=top></span><span id=Codehighlighter1_1783_1872_Closed_Text style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff"><img src="http://www.cppblog.com/Images/dot.gif"></span><span id=Codehighlighter1_1783_1872_Open_Text><span style="COLOR: #000000">{<br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;MessageBox(error.ErrorMessage(),&#8221;ADO错误</span><span style="COLOR: #000000">!</span><span style="COLOR: #000000">&#8221;);<br><img src="http://www.cppblog.com/Images/OutliningIndicators/InBlock.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;MessageBox(error.Description(),&#8221;ADO错误</span><span style="COLOR: #000000">!</span><span style="COLOR: #000000">&#8221;);<br><img src="http://www.cppblog.com/Images/OutliningIndicators/ExpandedBlockEnd.gif" align=top>}</span></span></div>
<img src ="http://www.cppblog.com/Lee7/aggbug/53772.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/Lee7/" target="_blank">isabc</a> 2008-06-17 23:21 <a href="http://www.cppblog.com/Lee7/archive/2008/06/17/53772.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>存储过程示例</title><link>http://www.cppblog.com/Lee7/archive/2008/06/17/53700.html</link><dc:creator>isabc</dc:creator><author>isabc</author><pubDate>Tue, 17 Jun 2008 06:29:00 GMT</pubDate><guid>http://www.cppblog.com/Lee7/archive/2008/06/17/53700.html</guid><wfw:comment>http://www.cppblog.com/Lee7/comments/53700.html</wfw:comment><comments>http://www.cppblog.com/Lee7/archive/2008/06/17/53700.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/Lee7/comments/commentRss/53700.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/Lee7/services/trackbacks/53700.html</trackback:ping><description><![CDATA[<div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top><span style="COLOR: #000000"><br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #0000ff">CREATE</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #0000ff">PROCEDURE</span><span style="COLOR: #000000">&nbsp;CheckReadCard&nbsp;<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top>(</span><span style="COLOR: #008000">@card_id</span><span style="COLOR: #000000">&nbsp;</span><span style="FONT-WEIGHT: bold; COLOR: #000000">varchar</span><span style="COLOR: #000000">(</span><span style="FONT-WEIGHT: bold; COLOR: #800000">20</span><span style="COLOR: #000000">),&nbsp;<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #008000">@emp_id</span><span style="COLOR: #000000">&nbsp;</span><span style="FONT-WEIGHT: bold; COLOR: #000000">varchar</span><span style="COLOR: #000000">(</span><span style="FONT-WEIGHT: bold; COLOR: #800000">20</span><span style="COLOR: #000000">)&nbsp;output&nbsp;,&nbsp;</span><span style="COLOR: #008000">@emp_fname</span><span style="COLOR: #000000">&nbsp;</span><span style="FONT-WEIGHT: bold; COLOR: #000000">varchar</span><span style="COLOR: #000000">(</span><span style="FONT-WEIGHT: bold; COLOR: #800000">20</span><span style="COLOR: #000000">)&nbsp;output,&nbsp;</span><span style="COLOR: #008000">@depart_id</span><span style="COLOR: #000000">&nbsp;</span><span style="FONT-WEIGHT: bold; COLOR: #000000">varchar</span><span style="COLOR: #000000">(</span><span style="FONT-WEIGHT: bold; COLOR: #800000">30</span><span style="COLOR: #000000">)&nbsp;output,</span><span style="COLOR: #008000">@group_id</span><span style="COLOR: #000000">&nbsp;</span><span style="FONT-WEIGHT: bold; COLOR: #000000">varchar</span><span style="COLOR: #000000">(</span><span style="FONT-WEIGHT: bold; COLOR: #800000">12</span><span style="COLOR: #000000">)&nbsp;output,</span><span style="COLOR: #008000">@over_pwd</span><span style="COLOR: #000000">&nbsp;</span><span style="FONT-WEIGHT: bold; COLOR: #000000">varchar</span><span style="COLOR: #000000">(</span><span style="FONT-WEIGHT: bold; COLOR: #800000">12</span><span style="COLOR: #000000">)&nbsp;output,<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #008000">@card_times</span><span style="COLOR: #000000">&nbsp;</span><span style="FONT-WEIGHT: bold; COLOR: #000000">int</span><span style="COLOR: #000000">&nbsp;output,&nbsp;</span><span style="COLOR: #008000">@card_sequ</span><span style="COLOR: #000000">&nbsp;</span><span style="FONT-WEIGHT: bold; COLOR: #000000">int</span><span style="COLOR: #000000">&nbsp;output,&nbsp;</span><span style="COLOR: #008000">@cardkind</span><span style="COLOR: #000000">&nbsp;</span><span style="FONT-WEIGHT: bold; COLOR: #000000">int</span><span style="COLOR: #000000">&nbsp;output,&nbsp;</span><span style="COLOR: #008000">@daytime</span><span style="COLOR: #000000">&nbsp;</span><span style="FONT-WEIGHT: bold; COLOR: #000000">int</span><span style="COLOR: #000000">&nbsp;output,</span><span style="COLOR: #008000">@meal_times</span><span style="COLOR: #000000">&nbsp;</span><span style="FONT-WEIGHT: bold; COLOR: #000000">int</span><span style="COLOR: #000000">&nbsp;output,<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #008000">@card_balance</span><span style="COLOR: #000000">&nbsp;</span><span style="FONT-WEIGHT: bold; COLOR: #000000">money</span><span style="COLOR: #000000">&nbsp;output,&nbsp;</span><span style="COLOR: #008000">@daymaxmoney</span><span style="COLOR: #000000">&nbsp;</span><span style="FONT-WEIGHT: bold; COLOR: #000000">money</span><span style="COLOR: #000000">&nbsp;output,&nbsp;</span><span style="COLOR: #008000">@timemaxmoney</span><span style="COLOR: #000000">&nbsp;</span><span style="FONT-WEIGHT: bold; COLOR: #000000">money</span><span style="COLOR: #000000">&nbsp;output,</span><span style="COLOR: #008000">@day_money</span><span style="COLOR: #000000">&nbsp;</span><span style="FONT-WEIGHT: bold; COLOR: #000000">money</span><span style="COLOR: #000000">&nbsp;output,<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #008000">@cardbegdate</span><span style="COLOR: #000000">&nbsp;</span><span style="FONT-WEIGHT: bold; COLOR: #000000">datetime</span><span style="COLOR: #000000">&nbsp;output,&nbsp;</span><span style="COLOR: #008000">@cardenddate</span><span style="COLOR: #000000">&nbsp;</span><span style="FONT-WEIGHT: bold; COLOR: #000000">datetime</span><span style="COLOR: #000000">&nbsp;output,&nbsp;</span><span style="COLOR: #008000">@group_info</span><span style="COLOR: #000000">&nbsp;</span><span style="FONT-WEIGHT: bold; COLOR: #000000">varchar</span><span style="COLOR: #000000">(</span><span style="FONT-WEIGHT: bold; COLOR: #800000">30</span><span style="COLOR: #000000">)&nbsp;output,<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #008000">@result</span><span style="COLOR: #000000">&nbsp;</span><span style="FONT-WEIGHT: bold; COLOR: #000000">int</span><span style="COLOR: #000000">&nbsp;output)<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #0000ff">AS</span><span style="COLOR: #000000"><br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #0000ff">DECLARE</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #008000">@i</span><span style="COLOR: #000000">&nbsp;</span><span style="FONT-WEIGHT: bold; COLOR: #000000">int</span><span style="COLOR: #000000"><br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #0000ff">DECLARE</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #008000">@Issued</span><span style="COLOR: #000000">&nbsp;</span><span style="FONT-WEIGHT: bold; COLOR: #000000">bit</span><span style="COLOR: #000000">&nbsp;<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #0000ff">SET</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #008000">@result</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #808080">=</span><span style="COLOR: #000000">&nbsp;</span><span style="FONT-WEIGHT: bold; COLOR: #800000">0</span><span style="COLOR: #000000"><br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #0000ff">SELECT</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #008000">@emp_id</span><span style="COLOR: #808080">=</span><span style="COLOR: #000000">emp_id,<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #008000">@emp_fname</span><span style="COLOR: #808080">=</span><span style="COLOR: #ff00ff">ISNULL</span><span style="COLOR: #000000">(emp_fname,</span><span style="COLOR: #ff0000">''</span><span style="COLOR: #000000">),&nbsp;<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #008000">@depart_id</span><span style="COLOR: #808080">=</span><span style="COLOR: #ff00ff">ISNULL</span><span style="COLOR: #000000">(depart_id,</span><span style="COLOR: #ff0000">'</span><span style="COLOR: #ff0000">0</span><span style="COLOR: #ff0000">'</span><span style="COLOR: #000000">),<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #008000">@group_id</span><span style="COLOR: #808080">=</span><span style="COLOR: #ff00ff">ISNULL</span><span style="COLOR: #000000">(E.group_id,&nbsp;</span><span style="COLOR: #ff0000">'</span><span style="COLOR: #ff0000">0</span><span style="COLOR: #ff0000">'</span><span style="COLOR: #000000">),<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #008000">@over_pwd</span><span style="COLOR: #808080">=</span><span style="COLOR: #ff00ff">ISNULL</span><span style="COLOR: #000000">(over_pwd,</span><span style="COLOR: #ff0000">'</span><span style="COLOR: #ff0000">000000</span><span style="COLOR: #ff0000">'</span><span style="COLOR: #000000">),&nbsp;<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #008000">@card_times</span><span style="COLOR: #808080">=</span><span style="COLOR: #ff00ff">ISNULL</span><span style="COLOR: #000000">(card_times,&nbsp;</span><span style="FONT-WEIGHT: bold; COLOR: #800000">0</span><span style="COLOR: #000000">),<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #008000">@card_balance</span><span style="COLOR: #808080">=</span><span style="COLOR: #ff00ff">ISNULL</span><span style="COLOR: #000000">(card_balance,&nbsp;</span><span style="FONT-WEIGHT: bold; COLOR: #800000">0</span><span style="COLOR: #000000">),<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #008000">@cardbegdate</span><span style="COLOR: #808080">=</span><span style="COLOR: #ff00ff">ISNULL</span><span style="COLOR: #000000">(CardBegDate,</span><span style="COLOR: #ff00ff">GETDATE</span><span style="COLOR: #000000">()),&nbsp;<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #008000">@cardenddate</span><span style="COLOR: #808080">=</span><span style="COLOR: #ff00ff">ISNULL</span><span style="COLOR: #000000">(CardEndDate,</span><span style="COLOR: #ff00ff">GETDATE</span><span style="COLOR: #000000">()),&nbsp;<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #008000">@card_sequ</span><span style="COLOR: #808080">=</span><span style="COLOR: #ff00ff">ISNULL</span><span style="COLOR: #000000">(Card_Sequ,&nbsp;</span><span style="FONT-WEIGHT: bold; COLOR: #800000">0</span><span style="COLOR: #000000">),<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #008000">@DayMaxMoney</span><span style="COLOR: #808080">=</span><span style="COLOR: #ff00ff">ISNULL</span><span style="COLOR: #000000">(DayMaxMoney,&nbsp;</span><span style="FONT-WEIGHT: bold; COLOR: #800000">0</span><span style="COLOR: #000000">),<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #008000">@DayTime</span><span style="COLOR: #808080">=</span><span style="COLOR: #ff00ff">ISNULL</span><span style="COLOR: #000000">(DayTime,&nbsp;</span><span style="FONT-WEIGHT: bold; COLOR: #800000">0</span><span style="COLOR: #000000">),<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #008000">@TimeMaxMoney</span><span style="COLOR: #808080">=</span><span style="COLOR: #ff00ff">ISNULL</span><span style="COLOR: #000000">(TimeMaxMoney,&nbsp;</span><span style="FONT-WEIGHT: bold; COLOR: #800000">0</span><span style="COLOR: #000000">),<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #008000">@CardKind</span><span style="COLOR: #808080">=</span><span style="COLOR: #ff00ff">ISNULL</span><span style="COLOR: #000000">(CardKind,&nbsp;</span><span style="FONT-WEIGHT: bold; COLOR: #800000">0</span><span style="COLOR: #000000">),<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #008000">@Issued</span><span style="COLOR: #808080">=</span><span style="COLOR: #ff00ff">ISNULL</span><span style="COLOR: #000000">(Issued,&nbsp;</span><span style="FONT-WEIGHT: bold; COLOR: #800000">0</span><span style="COLOR: #000000">),<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #008000">@group_info</span><span style="COLOR: #808080">=</span><span style="COLOR: #ff00ff">ISNULL</span><span style="COLOR: #000000">(group_info,</span><span style="COLOR: #ff0000">'</span><span style="COLOR: #ff0000">0</span><span style="COLOR: #ff0000">'</span><span style="COLOR: #000000">),<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #008000">@meal_times</span><span style="COLOR: #808080">=</span><span style="COLOR: #ff00ff">ISNULL</span><span style="COLOR: #000000">(meal_times,&nbsp;</span><span style="FONT-WEIGHT: bold; COLOR: #800000">0</span><span style="COLOR: #000000">),<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #008000">@day_money</span><span style="COLOR: #808080">=</span><span style="COLOR: #ff00ff">ISNULL</span><span style="COLOR: #000000">(day_money,</span><span style="FONT-WEIGHT: bold; COLOR: #800000">0</span><span style="COLOR: #000000">)&nbsp;<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #0000ff">FROM</span><span style="COLOR: #000000">&nbsp;Employee&nbsp;</span><span style="COLOR: #0000ff">AS</span><span style="COLOR: #000000">&nbsp;E&nbsp;</span><span style="COLOR: #ff00ff">LEFT</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #0000ff">JOIN</span><span style="COLOR: #000000">&nbsp;Groups&nbsp;</span><span style="COLOR: #0000ff">AS</span><span style="COLOR: #000000">&nbsp;G&nbsp;</span><span style="COLOR: #0000ff">ON</span><span style="COLOR: #000000">&nbsp;E.group_id</span><span style="COLOR: #808080">=</span><span style="COLOR: #000000">G.group_id&nbsp;</span><span style="COLOR: #0000ff">WHERE</span><span style="COLOR: #000000">&nbsp;card_id</span><span style="COLOR: #808080">=</span><span style="COLOR: #008000">@card_id</span><span style="COLOR: #000000"><br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #0000ff">IF</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #008000">@emp_id</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #0000ff">is</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #0000ff">null</span><span style="COLOR: #000000"><br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">SET</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #008000">@result</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #808080">=</span><span style="COLOR: #000000">&nbsp;</span><span style="FONT-WEIGHT: bold; COLOR: #800000">1</span><span style="COLOR: #000000"><br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #0000ff">ELSE</span><span style="COLOR: #000000"><br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #0000ff">BEGIN</span><span style="COLOR: #000000"><br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">SET</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #008000">@result</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #808080">=</span><span style="COLOR: #000000">&nbsp;</span><span style="FONT-WEIGHT: bold; COLOR: #800000">2</span><span style="COLOR: #000000"><br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">IF</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #008000">@Issued</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #808080">=</span><span style="COLOR: #000000">&nbsp;</span><span style="FONT-WEIGHT: bold; COLOR: #800000">0</span><span style="COLOR: #000000">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">SET</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #008000">@result</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #808080">=</span><span style="COLOR: #000000">&nbsp;</span><span style="FONT-WEIGHT: bold; COLOR: #800000">4</span><span style="COLOR: #000000"><br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">SELECT</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #008000">@i</span><span style="COLOR: #808080">=</span><span style="COLOR: #ff00ff">ISNULL</span><span style="COLOR: #000000">(</span><span style="COLOR: #ff00ff">count</span><span style="COLOR: #000000">(card_id),</span><span style="FONT-WEIGHT: bold; COLOR: #800000">0</span><span style="COLOR: #000000">)&nbsp;</span><span style="COLOR: #0000ff">FROM</span><span style="COLOR: #000000">&nbsp;AssignEmp&nbsp;</span><span style="COLOR: #0000ff">WHERE</span><span style="COLOR: #000000">&nbsp;card_id</span><span style="COLOR: #808080">=</span><span style="COLOR: #008000">@card_id</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #808080">and</span><span style="COLOR: #000000">&nbsp;Kind</span><span style="COLOR: #808080">=</span><span style="FONT-WEIGHT: bold; COLOR: #800000">2</span><span style="COLOR: #000000">&nbsp;&nbsp;&nbsp;&nbsp;<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">IF</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #008000">@i</span><span style="COLOR: #808080">&gt;</span><span style="FONT-WEIGHT: bold; COLOR: #800000">0</span><span style="COLOR: #000000">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="COLOR: #0000ff">SET</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #008000">@result</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #808080">=</span><span style="COLOR: #000000">&nbsp;</span><span style="FONT-WEIGHT: bold; COLOR: #800000">3</span><span style="COLOR: #000000"><br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #0000ff">END</span><span style="COLOR: #000000"><br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top><br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #0000ff">GO</span><span style="COLOR: #000000"><br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top></span></div>
<img src ="http://www.cppblog.com/Lee7/aggbug/53700.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/Lee7/" target="_blank">isabc</a> 2008-06-17 14:29 <a href="http://www.cppblog.com/Lee7/archive/2008/06/17/53700.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>SQL创建数据库示例代码</title><link>http://www.cppblog.com/Lee7/archive/2008/06/17/53678.html</link><dc:creator>isabc</dc:creator><author>isabc</author><pubDate>Tue, 17 Jun 2008 03:43:00 GMT</pubDate><guid>http://www.cppblog.com/Lee7/archive/2008/06/17/53678.html</guid><wfw:comment>http://www.cppblog.com/Lee7/comments/53678.html</wfw:comment><comments>http://www.cppblog.com/Lee7/archive/2008/06/17/53678.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/Lee7/comments/commentRss/53678.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/Lee7/services/trackbacks/53678.html</trackback:ping><description><![CDATA[<div style="BORDER-RIGHT: #cccccc 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: #cccccc 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: #cccccc 1px solid; WIDTH: 98%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: #cccccc 1px solid; BACKGROUND-COLOR: #eeeeee"><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top><span style="COLOR: #0000ff">create</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #0000ff">database</span><span style="COLOR: #000000">&nbsp;Test<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #0000ff">go</span><span style="COLOR: #000000"><br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #0000ff">Use</span><span style="COLOR: #000000">&nbsp;Test<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #0000ff">go</span><span style="COLOR: #000000"><br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #0000ff">create</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #0000ff">table</span><span style="COLOR: #000000">&nbsp;dbo.AutoTestLog<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top>(<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;IsError&nbsp;</span><span style="FONT-WEIGHT: bold; COLOR: #000000">bit</span><span style="COLOR: #000000">,<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;Info&nbsp;</span><span style="FONT-WEIGHT: bold; COLOR: #000000">varchar</span><span style="COLOR: #000000">(</span><span style="FONT-WEIGHT: bold; COLOR: #800000">2000</span><span style="COLOR: #000000">),<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;TestDate&nbsp;</span><span style="FONT-WEIGHT: bold; COLOR: #000000">dateTime</span><span style="COLOR: #000000">,<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;OP_user&nbsp;</span><span style="FONT-WEIGHT: bold; COLOR: #000000">int</span><span style="COLOR: #000000">,<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;GroupNO&nbsp;</span><span style="FONT-WEIGHT: bold; COLOR: #000000">varchar</span><span style="COLOR: #000000">(</span><span style="FONT-WEIGHT: bold; COLOR: #800000">10</span><span style="COLOR: #000000">),<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;</span><span style="COLOR: #ff0000">[</span><span style="COLOR: #ff0000">ID</span><span style="COLOR: #ff0000">]</span><span style="COLOR: #000000">&nbsp;</span><span style="FONT-WEIGHT: bold; COLOR: #000000">int</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #ff00ff">identity</span><span style="COLOR: #000000">(</span><span style="FONT-WEIGHT: bold; COLOR: #800000">1</span><span style="COLOR: #000000">,</span><span style="FONT-WEIGHT: bold; COLOR: #800000">1</span><span style="COLOR: #000000">)&nbsp;</span><span style="COLOR: #0000ff">primary</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #0000ff">key</span><span style="COLOR: #000000">&nbsp;,<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;LedAddress&nbsp;</span><span style="FONT-WEIGHT: bold; COLOR: #000000">int</span><span style="COLOR: #000000">,<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;Serino&nbsp;</span><span style="FONT-WEIGHT: bold; COLOR: #000000">varchar</span><span style="COLOR: #000000">(</span><span style="FONT-WEIGHT: bold; COLOR: #800000">30</span><span style="COLOR: #000000">)<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top>)<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #0000ff">go</span><span style="COLOR: #000000"><br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #0000ff">create</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #0000ff">table</span><span style="COLOR: #000000">&nbsp;dbo.BatchPlan<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top>(<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;BatchNo&nbsp;</span><span style="FONT-WEIGHT: bold; COLOR: #000000">varchar</span><span style="COLOR: #000000">(</span><span style="FONT-WEIGHT: bold; COLOR: #800000">30</span><span style="COLOR: #000000">)&nbsp;</span><span style="COLOR: #0000ff">primary</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #0000ff">key</span><span style="COLOR: #000000">,<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;state&nbsp;</span><span style="FONT-WEIGHT: bold; COLOR: #000000">varchar</span><span style="COLOR: #000000">(</span><span style="FONT-WEIGHT: bold; COLOR: #800000">30</span><span style="COLOR: #000000">),<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;ProductType&nbsp;</span><span style="FONT-WEIGHT: bold; COLOR: #000000">varchar</span><span style="COLOR: #000000">(</span><span style="FONT-WEIGHT: bold; COLOR: #800000">50</span><span style="COLOR: #000000">),<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;jiqicount&nbsp;</span><span style="FONT-WEIGHT: bold; COLOR: #000000">int</span><span style="COLOR: #000000"><br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top>)<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #0000ff">go</span><span style="COLOR: #000000"><br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #0000ff">create</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #0000ff">table</span><span style="COLOR: #000000">&nbsp;dbo.BatchPlandetail<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top>(<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;batchNo&nbsp;</span><span style="FONT-WEIGHT: bold; COLOR: #000000">varchar</span><span style="COLOR: #000000">(</span><span style="FONT-WEIGHT: bold; COLOR: #800000">30</span><span style="COLOR: #000000">)&nbsp;,<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;LedAddress&nbsp;</span><span style="FONT-WEIGHT: bold; COLOR: #000000">int</span><span style="COLOR: #000000">,<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;</span><span style="COLOR: #0000ff">Primary</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #0000ff">key</span><span style="COLOR: #000000">(batchNo,LedAddress)<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top>)<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #0000ff">go</span><span style="COLOR: #000000"><br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #0000ff">create</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #0000ff">table</span><span style="COLOR: #000000">&nbsp;dbo.CrustList<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top>(<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;CrustbarCode&nbsp;</span><span style="FONT-WEIGHT: bold; COLOR: #000000">varchar</span><span style="COLOR: #000000">(</span><span style="FONT-WEIGHT: bold; COLOR: #800000">100</span><span style="COLOR: #000000">)&nbsp;</span><span style="COLOR: #0000ff">primary</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #0000ff">key</span><span style="COLOR: #000000">,<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;opUser&nbsp;</span><span style="FONT-WEIGHT: bold; COLOR: #000000">int</span><span style="COLOR: #000000">,<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;crustState&nbsp;</span><span style="FONT-WEIGHT: bold; COLOR: #000000">varchar</span><span style="COLOR: #000000">(</span><span style="FONT-WEIGHT: bold; COLOR: #800000">100</span><span style="COLOR: #000000">),<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;OpTime&nbsp;</span><span style="FONT-WEIGHT: bold; COLOR: #000000">dateTime</span><span style="COLOR: #000000">,<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;SeriNo&nbsp;</span><span style="FONT-WEIGHT: bold; COLOR: #000000">varchar</span><span style="COLOR: #000000">(</span><span style="FONT-WEIGHT: bold; COLOR: #800000">30</span><span style="COLOR: #000000">)<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top>)<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #0000ff">go</span><span style="COLOR: #000000"><br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #0000ff">create</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #0000ff">table</span><span style="COLOR: #000000">&nbsp;dbo.Departs<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top>(<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;</span><span style="COLOR: #ff0000">[</span><span style="COLOR: #ff0000">ID</span><span style="COLOR: #ff0000">]</span><span style="COLOR: #000000">&nbsp;</span><span style="FONT-WEIGHT: bold; COLOR: #000000">int</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #0000ff">primary</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #0000ff">key</span><span style="COLOR: #000000">,<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;Depart_Name&nbsp;</span><span style="FONT-WEIGHT: bold; COLOR: #000000">varchar</span><span style="COLOR: #000000">(</span><span style="FONT-WEIGHT: bold; COLOR: #800000">50</span><span style="COLOR: #000000">)<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top>)<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #0000ff">go</span><span style="COLOR: #000000"><br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #0000ff">create</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #0000ff">table</span><span style="COLOR: #000000">&nbsp;dbo.Led<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top>(<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;Address&nbsp;</span><span style="FONT-WEIGHT: bold; COLOR: #000000">int</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #0000ff">primary</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #0000ff">key</span><span style="COLOR: #000000"><br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top>)<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #0000ff">go</span><span style="COLOR: #000000"><br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #0000ff">create</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #0000ff">table</span><span style="COLOR: #000000">&nbsp;dbo.Logs<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top>(<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;</span><span style="COLOR: #ff0000">[</span><span style="COLOR: #ff0000">id</span><span style="COLOR: #ff0000">]</span><span style="COLOR: #000000">&nbsp;</span><span style="FONT-WEIGHT: bold; COLOR: #000000">int</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #ff00ff">identity</span><span style="COLOR: #000000">(</span><span style="FONT-WEIGHT: bold; COLOR: #800000">1</span><span style="COLOR: #000000">,</span><span style="FONT-WEIGHT: bold; COLOR: #800000">1</span><span style="COLOR: #000000">)&nbsp;</span><span style="COLOR: #0000ff">primary</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #0000ff">key</span><span style="COLOR: #000000">,<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;Computer&nbsp;</span><span style="FONT-WEIGHT: bold; COLOR: #000000">varchar</span><span style="COLOR: #000000">(</span><span style="FONT-WEIGHT: bold; COLOR: #800000">10</span><span style="COLOR: #000000">),<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;Mode_Name&nbsp;</span><span style="FONT-WEIGHT: bold; COLOR: #000000">varchar</span><span style="COLOR: #000000">(</span><span style="FONT-WEIGHT: bold; COLOR: #800000">50</span><span style="COLOR: #000000">),<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;Operate&nbsp;</span><span style="FONT-WEIGHT: bold; COLOR: #000000">varchar</span><span style="COLOR: #000000">(</span><span style="FONT-WEIGHT: bold; COLOR: #800000">50</span><span style="COLOR: #000000">),<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;OP_Date&nbsp;</span><span style="FONT-WEIGHT: bold; COLOR: #000000">datetime</span><span style="COLOR: #000000">,<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;OP_user&nbsp;</span><span style="FONT-WEIGHT: bold; COLOR: #000000">int</span><span style="COLOR: #000000"><br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top>)<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #0000ff">go</span><span style="COLOR: #000000"><br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #0000ff">create</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #0000ff">table</span><span style="COLOR: #000000">&nbsp;dbo.MainBoard<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top>(<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;barCode&nbsp;</span><span style="FONT-WEIGHT: bold; COLOR: #000000">varchar</span><span style="COLOR: #000000">(</span><span style="FONT-WEIGHT: bold; COLOR: #800000">100</span><span style="COLOR: #000000">)&nbsp;</span><span style="COLOR: #0000ff">primary</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #0000ff">key</span><span style="COLOR: #000000">,<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;OPUser&nbsp;</span><span style="FONT-WEIGHT: bold; COLOR: #000000">int</span><span style="COLOR: #000000">,<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;state&nbsp;</span><span style="FONT-WEIGHT: bold; COLOR: #000000">varchar</span><span style="COLOR: #000000">(</span><span style="FONT-WEIGHT: bold; COLOR: #800000">100</span><span style="COLOR: #000000">)&nbsp;</span><span style="COLOR: #808080">not</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #0000ff">null</span><span style="COLOR: #000000">,<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;opTime&nbsp;</span><span style="FONT-WEIGHT: bold; COLOR: #000000">datetime</span><span style="COLOR: #000000">,<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;BoardID&nbsp;</span><span style="FONT-WEIGHT: bold; COLOR: #000000">varchar</span><span style="COLOR: #000000">(</span><span style="FONT-WEIGHT: bold; COLOR: #800000">30</span><span style="COLOR: #000000">)<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top>)<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #0000ff">go</span><span style="COLOR: #000000"><br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #0000ff">create</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #0000ff">table</span><span style="COLOR: #000000">&nbsp;dbo.Maintains<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top>(<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;</span><span style="COLOR: #ff0000">[</span><span style="COLOR: #ff0000">id</span><span style="COLOR: #ff0000">]</span><span style="COLOR: #000000">&nbsp;</span><span style="FONT-WEIGHT: bold; COLOR: #000000">int</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #ff00ff">identity</span><span style="COLOR: #000000">(</span><span style="FONT-WEIGHT: bold; COLOR: #800000">1</span><span style="COLOR: #000000">,</span><span style="FONT-WEIGHT: bold; COLOR: #800000">1</span><span style="COLOR: #000000">)&nbsp;</span><span style="COLOR: #0000ff">primary</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #0000ff">key</span><span style="COLOR: #000000">,<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;Product_ID&nbsp;</span><span style="FONT-WEIGHT: bold; COLOR: #000000">varchar</span><span style="COLOR: #000000">(</span><span style="FONT-WEIGHT: bold; COLOR: #800000">10</span><span style="COLOR: #000000">),<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;Problems&nbsp;</span><span style="FONT-WEIGHT: bold; COLOR: #000000">varchar</span><span style="COLOR: #000000">(</span><span style="FONT-WEIGHT: bold; COLOR: #800000">50</span><span style="COLOR: #000000">),<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;isIn&nbsp;</span><span style="FONT-WEIGHT: bold; COLOR: #000000">bit</span><span style="COLOR: #000000">,<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;op_date&nbsp;</span><span style="FONT-WEIGHT: bold; COLOR: #000000">datetime</span><span style="COLOR: #000000">,<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;op_User&nbsp;</span><span style="FONT-WEIGHT: bold; COLOR: #000000">int</span><span style="COLOR: #000000"><br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top>)<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #0000ff">go</span><span style="COLOR: #000000"><br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #0000ff">create</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #0000ff">table</span><span style="COLOR: #000000">&nbsp;dbo.Product<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top>(<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;CrustBarCode&nbsp;</span><span style="FONT-WEIGHT: bold; COLOR: #000000">varchar</span><span style="COLOR: #000000">(</span><span style="FONT-WEIGHT: bold; COLOR: #800000">30</span><span style="COLOR: #000000">)&nbsp;</span><span style="COLOR: #808080">not</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #0000ff">null</span><span style="COLOR: #000000">,&nbsp;<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;SeriNo&nbsp;</span><span style="FONT-WEIGHT: bold; COLOR: #000000">varchar</span><span style="COLOR: #000000">(</span><span style="FONT-WEIGHT: bold; COLOR: #800000">30</span><span style="COLOR: #000000">)&nbsp;</span><span style="COLOR: #808080">not</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #0000ff">null</span><span style="COLOR: #000000">,<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;opUser&nbsp;</span><span style="FONT-WEIGHT: bold; COLOR: #000000">int</span><span style="COLOR: #000000">,<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;opTime&nbsp;</span><span style="FONT-WEIGHT: bold; COLOR: #000000">datetime</span><span style="COLOR: #000000"><br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top>)<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #0000ff">go</span><span style="COLOR: #000000"><br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #0000ff">create</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #0000ff">table</span><span style="COLOR: #000000">&nbsp;dbo.ProductType<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top>(<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;Product_ID&nbsp;</span><span style="FONT-WEIGHT: bold; COLOR: #000000">varchar</span><span style="COLOR: #000000">(</span><span style="FONT-WEIGHT: bold; COLOR: #800000">10</span><span style="COLOR: #000000">)&nbsp;</span><span style="COLOR: #808080">not</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #0000ff">null</span><span style="COLOR: #000000">,<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;&nbsp;Product_name&nbsp;</span><span style="FONT-WEIGHT: bold; COLOR: #000000">varchar</span><span style="COLOR: #000000">(</span><span style="FONT-WEIGHT: bold; COLOR: #800000">50</span><span style="COLOR: #000000">)<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top>)<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #0000ff">go</span><span style="COLOR: #000000"><br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #0000ff">create</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #0000ff">table</span><span style="COLOR: #000000">&nbsp;dbo.Users<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top>(<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;</span><span style="COLOR: #ff0000">[</span><span style="COLOR: #ff0000">ID</span><span style="COLOR: #ff0000">]</span><span style="COLOR: #000000">&nbsp;</span><span style="FONT-WEIGHT: bold; COLOR: #000000">int</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #ff00ff">identity</span><span style="COLOR: #000000">(</span><span style="FONT-WEIGHT: bold; COLOR: #800000">1</span><span style="COLOR: #000000">,</span><span style="FONT-WEIGHT: bold; COLOR: #800000">1</span><span style="COLOR: #000000">)&nbsp;</span><span style="COLOR: #0000ff">primary</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #0000ff">key</span><span style="COLOR: #000000">,<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;UserName&nbsp;</span><span style="FONT-WEIGHT: bold; COLOR: #000000">varchar</span><span style="COLOR: #000000">(</span><span style="FONT-WEIGHT: bold; COLOR: #800000">20</span><span style="COLOR: #000000">),<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;</span><span style="COLOR: #ff0000">[</span><span style="COLOR: #ff0000">password</span><span style="COLOR: #ff0000">]</span><span style="COLOR: #000000">&nbsp;</span><span style="FONT-WEIGHT: bold; COLOR: #000000">varchar</span><span style="COLOR: #000000">(</span><span style="FONT-WEIGHT: bold; COLOR: #800000">10</span><span style="COLOR: #000000">),<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;Depart_ID&nbsp;</span><span style="FONT-WEIGHT: bold; COLOR: #000000">int</span><span style="COLOR: #000000">,&nbsp;<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;rightClass&nbsp;</span><span style="FONT-WEIGHT: bold; COLOR: #000000">int</span><span style="COLOR: #000000">,<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top>&nbsp;LastDate&nbsp;</span><span style="FONT-WEIGHT: bold; COLOR: #000000">datetime</span><span style="COLOR: #000000"><br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top>)<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #0000ff">go</span><span style="COLOR: #000000"><br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #0000ff">INSERT</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #0000ff">INTO</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #ff0000">[</span><span style="COLOR: #ff0000">dbo</span><span style="COLOR: #ff0000">]</span><span style="COLOR: #000000">.</span><span style="COLOR: #ff0000">[</span><span style="COLOR: #ff0000">Departs</span><span style="COLOR: #ff0000">]</span><span style="COLOR: #000000">(</span><span style="COLOR: #ff0000">[</span><span style="COLOR: #ff0000">ID</span><span style="COLOR: #ff0000">]</span><span style="COLOR: #000000">,&nbsp;</span><span style="COLOR: #ff0000">[</span><span style="COLOR: #ff0000">Depart_Name</span><span style="COLOR: #ff0000">]</span><span style="COLOR: #000000">)<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #0000ff">VALUES</span><span style="COLOR: #000000">(</span><span style="FONT-WEIGHT: bold; COLOR: #800000">1</span><span style="COLOR: #000000">,</span><span style="COLOR: #ff0000">'</span><span style="COLOR: #ff0000">测试</span><span style="COLOR: #ff0000">'</span><span style="COLOR: #000000">)<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #0000ff">go</span><span style="COLOR: #000000"><br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #0000ff">INSERT</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #0000ff">INTO</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #ff0000">[</span><span style="COLOR: #ff0000">dbo</span><span style="COLOR: #ff0000">]</span><span style="COLOR: #000000">.</span><span style="COLOR: #ff0000">[</span><span style="COLOR: #ff0000">Users</span><span style="COLOR: #ff0000">]</span><span style="COLOR: #000000">(&nbsp;</span><span style="COLOR: #ff0000">[</span><span style="COLOR: #ff0000">UserName</span><span style="COLOR: #ff0000">]</span><span style="COLOR: #000000">,&nbsp;</span><span style="COLOR: #ff0000">[</span><span style="COLOR: #ff0000">Password</span><span style="COLOR: #ff0000">]</span><span style="COLOR: #000000">,&nbsp;</span><span style="COLOR: #ff0000">[</span><span style="COLOR: #ff0000">Depart_ID</span><span style="COLOR: #ff0000">]</span><span style="COLOR: #000000">,&nbsp;</span><span style="COLOR: #ff0000">[</span><span style="COLOR: #ff0000">RightClass</span><span style="COLOR: #ff0000">]</span><span style="COLOR: #000000">,&nbsp;</span><span style="COLOR: #ff0000">[</span><span style="COLOR: #ff0000">LastDate</span><span style="COLOR: #ff0000">]</span><span style="COLOR: #000000">)<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #0000ff">VALUES</span><span style="COLOR: #000000">(&nbsp;</span><span style="COLOR: #ff0000">'</span><span style="COLOR: #ff0000">Test</span><span style="COLOR: #ff0000">'</span><span style="COLOR: #000000">,&nbsp;</span><span style="COLOR: #ff0000">'</span><span style="COLOR: #ff0000">123456</span><span style="COLOR: #ff0000">'</span><span style="COLOR: #000000">,&nbsp;</span><span style="FONT-WEIGHT: bold; COLOR: #800000">1</span><span style="COLOR: #000000">,&nbsp;</span><span style="FONT-WEIGHT: bold; COLOR: #800000">3</span><span style="COLOR: #000000">,&nbsp;</span><span style="COLOR: #ff00ff">Getdate</span><span style="COLOR: #000000">())<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #0000ff">go</span><span style="COLOR: #000000"><br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #0000ff">INSERT</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #0000ff">INTO</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #ff0000">[</span><span style="COLOR: #ff0000">dbo</span><span style="COLOR: #ff0000">]</span><span style="COLOR: #000000">.</span><span style="COLOR: #ff0000">[</span><span style="COLOR: #ff0000">ProductType</span><span style="COLOR: #ff0000">]</span><span style="COLOR: #000000">(</span><span style="COLOR: #ff0000">[</span><span style="COLOR: #ff0000">Product_ID</span><span style="COLOR: #ff0000">]</span><span style="COLOR: #000000">,&nbsp;</span><span style="COLOR: #ff0000">[</span><span style="COLOR: #ff0000">Product_Name</span><span style="COLOR: #ff0000">]</span><span style="COLOR: #000000">)<br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #0000ff">select</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #ff0000">'</span><span style="COLOR: #ff0000">1</span><span style="COLOR: #ff0000">'</span><span style="COLOR: #000000">,</span><span style="COLOR: #ff0000">'</span><span style="COLOR: #ff0000">690</span><span style="COLOR: #ff0000">'</span><span style="COLOR: #000000"><br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #0000ff">union</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #808080">all</span><span style="COLOR: #000000"><br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #0000ff">select</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #ff0000">'</span><span style="COLOR: #ff0000">2</span><span style="COLOR: #ff0000">'</span><span style="COLOR: #000000">,</span><span style="COLOR: #ff0000">'</span><span style="COLOR: #ff0000">890</span><span style="COLOR: #ff0000">'</span><span style="COLOR: #000000"><br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #0000ff">union</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #808080">all</span><span style="COLOR: #000000"><br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #0000ff">select</span><span style="COLOR: #000000">&nbsp;</span><span style="COLOR: #ff0000">'</span><span style="COLOR: #ff0000">3</span><span style="COLOR: #ff0000">'</span><span style="COLOR: #000000">,</span><span style="COLOR: #ff0000">'</span><span style="COLOR: #ff0000">981</span><span style="COLOR: #ff0000">'</span><span style="COLOR: #000000"><br><img src="http://www.cppblog.com/Images/OutliningIndicators/None.gif" align=top></span><span style="COLOR: #0000ff">go</span></div>
<img src ="http://www.cppblog.com/Lee7/aggbug/53678.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/Lee7/" target="_blank">isabc</a> 2008-06-17 11:43 <a href="http://www.cppblog.com/Lee7/archive/2008/06/17/53678.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>用SQL创建数据库</title><link>http://www.cppblog.com/Lee7/archive/2008/06/16/53593.html</link><dc:creator>isabc</dc:creator><author>isabc</author><pubDate>Mon, 16 Jun 2008 13:00:00 GMT</pubDate><guid>http://www.cppblog.com/Lee7/archive/2008/06/16/53593.html</guid><wfw:comment>http://www.cppblog.com/Lee7/comments/53593.html</wfw:comment><comments>http://www.cppblog.com/Lee7/archive/2008/06/16/53593.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.cppblog.com/Lee7/comments/commentRss/53593.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/Lee7/services/trackbacks/53593.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: 首先说说怎么用SQL语句创建数据库，创建数据库的语句有如下几种：  <br>   1. CREATE TABLE（创建新表）  <br>   2. CREATE INDEX（增加索引）  <br>   3. DROP INDEX（删除索引）  <br>   4. CONSTRAINT（约束语句）  <br>   5. ALTER TABLE（修改表）  <br>   6. DROP TABLE（删除表）  <br>&nbsp;&nbsp;<a href='http://www.cppblog.com/Lee7/archive/2008/06/16/53593.html'>阅读全文</a><img src ="http://www.cppblog.com/Lee7/aggbug/53593.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/Lee7/" target="_blank">isabc</a> 2008-06-16 21:00 <a href="http://www.cppblog.com/Lee7/archive/2008/06/16/53593.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>什么是存储过程?</title><link>http://www.cppblog.com/Lee7/archive/2008/06/16/53586.html</link><dc:creator>isabc</dc:creator><author>isabc</author><pubDate>Mon, 16 Jun 2008 12:10:00 GMT</pubDate><guid>http://www.cppblog.com/Lee7/archive/2008/06/16/53586.html</guid><wfw:comment>http://www.cppblog.com/Lee7/comments/53586.html</wfw:comment><comments>http://www.cppblog.com/Lee7/archive/2008/06/16/53586.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/Lee7/comments/commentRss/53586.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/Lee7/services/trackbacks/53586.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: 将常用的或很复杂的工作，预先用SQL语句写好并用一个指定的名称存储起来,   那么以后要叫数据库提供与已定义好的存储过程的功能相同的服务时,只需调用execute,即可自动完成命令。&nbsp;&nbsp;<a href='http://www.cppblog.com/Lee7/archive/2008/06/16/53586.html'>阅读全文</a><img src ="http://www.cppblog.com/Lee7/aggbug/53586.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/Lee7/" target="_blank">isabc</a> 2008-06-16 20:10 <a href="http://www.cppblog.com/Lee7/archive/2008/06/16/53586.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>VC调用存储过程的通用方法（SQLServer篇）</title><link>http://www.cppblog.com/Lee7/archive/2008/06/16/53584.html</link><dc:creator>isabc</dc:creator><author>isabc</author><pubDate>Mon, 16 Jun 2008 11:56:00 GMT</pubDate><guid>http://www.cppblog.com/Lee7/archive/2008/06/16/53584.html</guid><wfw:comment>http://www.cppblog.com/Lee7/comments/53584.html</wfw:comment><comments>http://www.cppblog.com/Lee7/archive/2008/06/16/53584.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/Lee7/comments/commentRss/53584.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/Lee7/services/trackbacks/53584.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: VC调用SQLServer存储过程的通用方法，只需要普通的查询就可以实现。<br>这里讨论的是ADO调用存储过程，按MSDN的例子，一般都是下面的调用方法（节选自MSDN）：&nbsp;&nbsp;<a href='http://www.cppblog.com/Lee7/archive/2008/06/16/53584.html'>阅读全文</a><img src ="http://www.cppblog.com/Lee7/aggbug/53584.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/Lee7/" target="_blank">isabc</a> 2008-06-16 19:56 <a href="http://www.cppblog.com/Lee7/archive/2008/06/16/53584.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>关于用VC进行图像数据（二进制大对象）存储数据库的一点心得</title><link>http://www.cppblog.com/Lee7/archive/2008/06/13/53103.html</link><dc:creator>isabc</dc:creator><author>isabc</author><pubDate>Fri, 13 Jun 2008 01:21:00 GMT</pubDate><guid>http://www.cppblog.com/Lee7/archive/2008/06/13/53103.html</guid><wfw:comment>http://www.cppblog.com/Lee7/comments/53103.html</wfw:comment><comments>http://www.cppblog.com/Lee7/archive/2008/06/13/53103.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/Lee7/comments/commentRss/53103.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/Lee7/services/trackbacks/53103.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: 下面给出用VC如何操作图像文件存取数据库的原码，帮助一些还没有掌握方法的朋友，也请这方面的高手多多指教。（均用ADO连接数据库）&nbsp;&nbsp;<a href='http://www.cppblog.com/Lee7/archive/2008/06/13/53103.html'>阅读全文</a><img src ="http://www.cppblog.com/Lee7/aggbug/53103.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/Lee7/" target="_blank">isabc</a> 2008-06-13 09:21 <a href="http://www.cppblog.com/Lee7/archive/2008/06/13/53103.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>封装ADO编程Connection对象的类</title><link>http://www.cppblog.com/Lee7/archive/2008/06/10/52798.html</link><dc:creator>isabc</dc:creator><author>isabc</author><pubDate>Tue, 10 Jun 2008 13:20:00 GMT</pubDate><guid>http://www.cppblog.com/Lee7/archive/2008/06/10/52798.html</guid><wfw:comment>http://www.cppblog.com/Lee7/comments/52798.html</wfw:comment><comments>http://www.cppblog.com/Lee7/archive/2008/06/10/52798.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/Lee7/comments/commentRss/52798.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/Lee7/services/trackbacks/52798.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: &nbsp;//&nbsp;ADOConnection.cpp:&nbsp;implementation&nbsp;of&nbsp;the&nbsp;CADOConnection&nbsp;class.///**////////////////////////////////////////////////////////////////////////**//****************...&nbsp;&nbsp;<a href='http://www.cppblog.com/Lee7/archive/2008/06/10/52798.html'>阅读全文</a><img src ="http://www.cppblog.com/Lee7/aggbug/52798.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/Lee7/" target="_blank">isabc</a> 2008-06-10 21:20 <a href="http://www.cppblog.com/Lee7/archive/2008/06/10/52798.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>在Visual C++中如何利用UDL文件来建立ADO连接[转]</title><link>http://www.cppblog.com/Lee7/archive/2008/06/10/52784.html</link><dc:creator>isabc</dc:creator><author>isabc</author><pubDate>Tue, 10 Jun 2008 12:03:00 GMT</pubDate><guid>http://www.cppblog.com/Lee7/archive/2008/06/10/52784.html</guid><wfw:comment>http://www.cppblog.com/Lee7/comments/52784.html</wfw:comment><comments>http://www.cppblog.com/Lee7/archive/2008/06/10/52784.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/Lee7/comments/commentRss/52784.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/Lee7/services/trackbacks/52784.html</trackback:ping><description><![CDATA[&nbsp;&nbsp;&nbsp;&nbsp; 摘要: 　使用通用数据连接文件（*.UDL，以下简称文件）来创建ADO连接，可以和ODBC一样可视化地定义要连接的数据源，从而实现数据访问的透明性。 <br>&nbsp;&nbsp;<a href='http://www.cppblog.com/Lee7/archive/2008/06/10/52784.html'>阅读全文</a><img src ="http://www.cppblog.com/Lee7/aggbug/52784.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/Lee7/" target="_blank">isabc</a> 2008-06-10 20:03 <a href="http://www.cppblog.com/Lee7/archive/2008/06/10/52784.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>