简体   繁体   English

SQLHANDLE-Parameters:函数不带x个参数(但实际上有)

[英]SQLHANDLE-Parameters: function does not take x arguments (but it does, actually)

I implemented some function in c++ to handle sql-queries and stuff. 我在c ++中实现了一些功能来处理sql查询和其他内容。 Because I am doing this in different functions using the same handles, I am giving the handles as parameters (actually I want to inout references to the handles - but I am new to c++ and still having trouble understanding the concepts behind pointers and so). 因为我使用相同的句柄在不同的函数中执行此操作,所以我将句柄作为参数提供(实际上,我想输入对句柄的引用-但我对c ++还是陌生的,但仍然难以理解指针等的概念)。

Because the Error-Message is saying, that there is no function with x parameters, but there actually is one (there is a forward declaration as well), I think, that the definition and the use I am trying to make of it are somehow wrong. 因为错误消息说的是,没有带x参数的函数,但实际上有一个(还有一个前向声明),我认为我试图使用的定义和用法都在某种程度上错误。

Here is the forward declaration: 这是前向声明:

static HRESULT 
_OpenDatabase(
    LPCWSTR connectionString, 
    SQLHANDLE hdlStmt, 
    SQLHANDLE hdlEnv, 
    SQLHANDLE hdlConn
);

And the call (getting the connection string as input: __in LPCWSTR ConnectString) 和调用(获取连接字符串作为输入:__in LPCWSTR ConnectString)

SQLHANDLE hdlStmt = INVALID_HANDLE_VALUE;
SQLHANDLE hdlEnv = INVALID_HANDLE_VALUE;
SQLHANDLE hdlConn = INVALID_HANDLE_VALUE;
    hr = _OpenDatabase(
        ConnectString,
        &hdlStmt, // this might be wrong?
        &hdlEnv, // and this
        &hdlConn // and this
    );

What am I doing wrong? 我究竟做错了什么?

You're putting & in front of the arguments. 您将&放在论据的前面。 Why? 为什么? You have 3 SQLHANDLE , you need 3 SQLHANDLE . 您有3个SQLHANDLE ,您需要3个SQLHANDLE

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM