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

  • Home
  • SEARCH
  • 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 8021049
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T21:51:40+00:00 2026-06-04T21:51:40+00:00

I am attempting a quick prototype-port of some old database code over to use

  • 0

I am attempting a quick prototype-port of some old database code over to use the FreeTDS library. Currently, I am looking at a query similar to

SELECT x,y,z from MyTable WHERE id = @arg1

When I execute the query, I naturally get an error like Must declare the scalar variable "@arg1".

But one thing eludes me. How do I declare this variable? I have looked through the API docs and code examples over and over again and I can’t seem to find how to solve this should-be-trivial task.

The code I currently use is:

if(dbcmd(proc, "SELECT x,y,z from MyTable WHERE id = @arg1") != SUCCEED) {
  return fail("Failed to dbcmd()"); 
}

if(dbsqlexec(proc) != SUCCEED) {
  return fail("Failed to dbsqlexec()");
}

while((retcode=dbresults(proc)) == SUCCEED) {
  while(dbnextrow(proc) != NO_MORE_ROWS) {
    int len = dbdatlen(proc, 1);
    char* data = (char*)dbdata(proc, 1);
    cout << string(data, len) << endl;
  }
}
  • 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-06-04T21:51:41+00:00Added an answer on June 4, 2026 at 9:51 pm

    You can try either “DECLARE @MyVariable int” or “@arg1″, OleDbType.Integer” to add as dbcmd(dbproc, “HERE” ); after your dbcmd(proc,”SELECT …..”);

    dbcmd(dbproc,"SELECT x,y,z from MyTable WHERE id = @arg1");
    dbcmd(dbproc, "DECLARE @arg1 int" );
    

    I do’nt think if there is any API however I am sure this is the way you could use it.

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

Sidebar

Related Questions

I am attempting to do a quick replace of the 'innerHTML' of the 'code'
We are attempting to use a SQL Server 2003 database for our test records
I'm attempting to use PaperClip and have been following the quick start found on
Attempting to use the data series from this example no longer passes the JSONLint
Attempting to use XStream's JavaBeanConverter and running into an issue. Most likely I'm missng
Is there a more comprehensive quick start for drools 5. I was attempting to
Alright, here's what I'm trying to do. I'm attempting to write a quick build
Why Java impl choose merge sort over quick sort? and why do they copy
I am attempting to implement some additional statistics gathering in a C# server application
I am attempting to use System.Security.Cryptography.AesManaged to encrypt a file in my .net application.

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.