CSDN首页 空间 新闻 论坛 Blog 下载 读书 网摘 搜索 .NET Java 视频 接项目 求职 在线学习 买书 程序员 通知
可用分押宝游戏火热进行中... 专题改版:Java Web 专题
CSDN社区
搜索 收藏 打印 关闭
CSDN社区 >  MS-SQL Server >  疑难问题

sql

楼主zhangchenbo(zhangchenbo)2003-12-04 17:55:22 在 MS-SQL Server / 疑难问题 提问

怎吗在VC中用MFC中的ODBC数据库类(CDatabase,CRecordset)备份数据库,怎吗调用存储过程,有例子吗,发一个过来,多谢!信箱zhangchenbo1981@tom.com 问题点数:0、回复次数:4Top

1 楼txlicenhe(马可)回复于 2003-12-04 17:58:19 得分 0

去MFC版找贴子吧。Top

2 楼pengdali()回复于 2003-12-04 18:26:09 得分 0

below   is   from   MSDN,you   can   find   a   lot   of   technical   article   in   MSDN   if   you   search"stored   procedure   and   VC"  
  good   luck  
   
  Steps   To   Reproduce   Behavior  
  In   the   SQL   Server   7.0   Query   Analyzer   select   the   test   database   Pubs.  
   
   
  Create   the   following   stored   procedure.   This   stored   procedure   returns   a   recordset   and   an   out   parameter   count.  
   
   
   
  if   exists   (select   *   from   sysobjects   where   id   =   object_id(N'[dbo].[GetJobs]')   and   OBJECTPROPERTY(id,   N'IsProcedure')   =   1)  
        drop   proc   GetJobs  
        go  
        create   proc   GetJobs   @id   as   int,   @count   as   int   [out]   as  
        begin  
        Select   @count   =   Count(*)   from   jobs   where   job_id   >@id  
        Select   *   from   jobs   where   job_id   >@id  
        end  
        go  
     
   
   
   
  Use   VC   App   Wizard   to   create   a   new   console   application   and   modify   the   code   as   follows:  
   
   
   
  #include   "stdafx.h"  
        #include   "stdio.h"  
        #import   "C:\PROGRA~1\COMMON~1\System\ado\msado15.dll"   no_namespace   rename   ("EOF",   "EOF2")  
   
        struct   InitOle   {  
            InitOle()     {   ::CoInitialize(NULL);   }  
            ~InitOle()   {   ::CoUninitialize();       }  
        }   _init_InitOle_;  
   
        int   main(int   argc,   char*   argv[])  
        {  
        _variant_t   varErr((long)0,   VT_ERROR);  
        _CommandPtr   comm(__uuidof(Command));  
        _ConnectionPtr   conn(__uuidof(Connection));  
   
        _bstr_t   connstr="Provider=SQLOLEDB.1;Persist   Security   Info=False;User   ID=sa;Initial   Catalog=pubs;Data   Source=(local)";  
        conn->Open(connstr,   "",   "",   adConnectUnspecified);  
        comm->ActiveConnection=conn;  
        comm->CommandText="GetJobs";  
        comm->CommandType   =   adCmdStoredProc   ;    
        comm->Parameters->Refresh();  
        _variant_t   recs;  
   
        comm->Parameters->Item[_variant_t((short)1)]->Value=   _variant_t((long)5);  
        _RecordsetPtr   rs   =   comm->Execute(&recs,   &vtMissing,adCmdStoredProc);    
   
        _variant_t   recordcount=   comm->Parameters->Item[_variant_t((short)2)]->Value;  
   
        printf("recordcount   =   %li\n",   (long)recordcount);  
        return   0;  
        }  
     
   
   
  Change   the   Datasource,   User   ID   and   password   in   the   connection   string   above.  
   
   
   
   
  The   recordcount   variant   that   the   above   code   returns   is   of   type   VT_NULL   rather   than   the   number   of   records   that   the   stored   procedure   returns.  
  Top

3 楼pengdali()回复于 2003-12-04 18:26:43 得分 0

--备份  
  backup   database   sys   to   disk='c:\目录\a.bak'   with   init  
   
   
   
  --还原    
  USE   master    
  restore   database   数据名   from   disk='c:\test.bak'   with   REPLACETop

4 楼zhangchenbo(zhangchenbo)回复于 2003-12-06 18:16:01 得分 0

20Top

相关问题

  • SQL???
  • sql????????????????????
  • sql
  • SQL????
  • sql
  • sQl
  • sql
  • sql
  • sql???
  • SQL????

关键词

  • getjobs
  • job
  • stored procedure
  • count
  • create
  • where
  • select

得分解答快速导航

  • 帖主:zhangchenbo

相关链接

  • SQL Server类图书

广告也精彩

反馈

请通过下述方式给我们反馈
反馈
提问
网站简介|广告服务|VIP资费标准|银行汇款帐号|网站地图|帮助|联系方式|诚聘英才|English|问题报告
世纪乐知(北京)网络技术有限公司 版权所有, 京 ICP 证 020026 号
北京创新乐知广告有限公司 提供技术支持
Copyright © 2000-2007, CSDN.NET, All Rights Reserved
GongshangLogo