VC调用存储过程的通用方法(SQLServer篇)
这里讨论的是ADO调用存储过程,按MSDN的例子,一般都是下面的调用方法(节选自MSDN):
HRESULT hr = S_OK;
// Define ADO object pointers.
// Initialize pointers on define.
// These are in the ADODB:: namespace.
_RecordsetPtr pRstByRoyalty = NULL;
_RecordsetPtr pRstAuthors = NULL;
_CommandPtr pcmdByRoyalty = NULL;
_ParameterPtr pprmByRoyalty = NULL;
_ConnectionPtr pConnection = NULL;
_bstr_t strCnn("Provider=sqloledb;Data Source=srv;"
"Initial Catalog=Pubs;User Id=sa;Password=;");
_bstr_t strMessage, strAuthorID;
int intRoyalty;
VARIANT vtRoyalty;
try
{
//Open a Connection.
TESTHR(pConnection.CreateInstance(__uuidof(Connection)));
hr = pConnection->Open(strCnn,"","",NULL);
pConnection->CursorLocation = adUseClient;
//Open Command Object with one Parameter
TESTHR(pcmdByRoyalty.CreateInstance(__uuidof(Command)));
pcmdByRoyalty->CommandText = "byroyalty";
pcmdByRoyalty->CommandType = adCmdStoredProc;
//Define Integer/variant.
vtRoyalty.vt = VT_I2;
vtRoyalty.iVal = intRoyalty;
pprmByRoyalty = pcmdByRoyalty->CreateParameter(
"percentag
相关文档:
本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/yf520gn/archive/2008/09/26/2982363.aspx
SELECT * from TB_MILES_CB_ORDER
WHERE convert(varchar(100),ORDER_DATE,102)= ?
ORDER BY ORDER_NO
SELECT CONVERT(varchar(100), GETDATE(), 0): 05 16 2006 10:57AM
SELECT CONVERT(varchar(100), GETDATE ......
=================分页==========================
/*分页查找数据*/
CREATE PROCEDURE [dbo].[GetRecordSet]
@strSql varchar(8000),--查询sql,如select * from [user]
@PageIndex int,--查询当页号
@PageSize int--每页显示记录
AS
set nocount on
declare @p1 int
declare @current ......
· 本文讨论了如何通过Transact-SQL以及系统函数OPENDATASOURCE和OPENROWSET在同构和异构数据库之间进行数据的导入导出,并给出了详细的例子以供参考。
1. 在SQL Server数据库之间进行数据导入导出
(1).使用SELECT INTO导出数据
  ......
对数据库进行多表操作,如果表与表之间存在依赖,那么显式的使用事务,可以保持对数据库操作的原子性。用Python访问SqlServer数据库,我使用pymssql库。今天在使用这个库的时候,发现一个问题。
问题大概是这样的:
我有两张表,一张主表(ClassInfo),一张从表(Student),Student表通过外键ClassID与ClassI ......
declare @areaid varchar(100)
declare @areaname varchar(100)
declare Cur cursor for
select code as areaID,[name] as areaName from dbo.province
open Cur
Fetch next from Cur Into @areaid,@areaname
While @@fetch_status=0
Begin
print('insert into ......