Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 599253
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T16:28:40+00:00 2026-05-13T16:28:40+00:00

I have the following parameter being bound for calling a SQL procedure: TCHAR str[41];

  • 0

I have the following parameter being bound for calling a SQL procedure:

TCHAR str[41];
SQLINTEGER cb;
SQLBindParameter(hstmt, 1, SQL_PARAM_INPUT_OUTPUT, SQL_C_TCHAR, SQL_C_TCHAR, 40, 0, str, 0, &cb);

When I loop through str after calling the query I can see the result is there, but it’s not quite right:

std::stringstream ss;
ss<<"{";
for(int i=0;i<41;++i)
{
    ss<<(int)str[i];
    if(i<40)ss<<',';
}
ss<<"}"<<endl<<"{";
for(int i=0;i<41;++i)
{
    if(str[i])
        ss<<"'"<<str[i]<<"'";
    else
        ss<<"null";
    if(i<40)ss<<',';
}
ss<<"}"<<endl;
cout<<ss.str();

{53,55,56,49,53,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,32,0}
{‘5′,’7′,’8′,’1′,’5’,‘ ‘,’ ‘,’ ‘,’ ‘,’ ‘,’ ‘,’ ‘,’ ‘,’ ‘,’ ‘,’ ‘,’ ‘,’ ‘,’ ‘,’ ‘,’ ‘,’ ‘,’ ‘,’ ‘,’ ‘,’ ‘,’ ‘,’ ‘,’ ‘,’ ‘,’ ‘,’ ‘,’ ‘,’ ‘,’ ‘,’ ‘,’ ‘,’ ‘,’ ‘,’ ‘,null}

For whatever reason, str is being padded with spaces. I know the SQL procedure is actually returning “57815” from testing it in isolation. Any ideas what’s going on and how to resolve it?
The cb value is set to 40 after the SQL call is executed.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T16:28:41+00:00Added an answer on May 13, 2026 at 4:28 pm

    If the SQL database field is of type CHAR, it will be space padded (and if it isn’t a CHAR, what type is it?). This is expected behaviour. If it isn’t are you sure that SQL_C_TCHAR is the type you really want – it isn’t listed on this MSDN page.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have following code and i want to pass additional parameter in JSON.getJSONfromURL() method
I have the following code which takes List of boolean as a parameter then
In python I have the following function: def is_a_nice_element(element, parameter): #do something return True
Suppose I have an Oracle 11.2 database containing the following table: TABLE: SURVEY PARAMETER
I have the following code: http = Net::HTTP.new(www.something.com, 80) http.set_debug_output($stdout) http.post(/blah, something, {'random-parameter' =>
I have an SQL Server Express 2012 with the following event model in the
I got this following error when my website was being audited. I have developed
I have a bean being created by a service with the following class: @Configuration
Say I have a model called User that has the following parameters: favorite_color, favorite_animal,
I have the following function //simple function with parameters and variable function thirdfunction(a,b,c,d){ console.log(the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.