CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Guest

    SQL Stored Procedures

    All I want to do is hard code two parameters to a stored procedure. I have tried
    {call MyProc ('StringParam') , 56}
    {call MyProc 'StringParam' , 56}
    {call MyProc ('StringParam') , (56)}
    {call MyProc 'StringParam' , 56}
    {call MyProc 'StringParam' 56}
    {call MyProc ('StringParam') (56)}

    and nothing works - I get 'syntax error or access violation when opening the record set. Hard coding a single parameter stored procedure works a treat :-

    {call MyProc ('StringParam')}

    Please help. Could you also mail me back on [email protected] as I am still waiting my login password to this forum. Thanks.



  2. #2
    Join Date
    May 1999
    Posts
    5

    Re: SQL Stored Procedures

    Try to format parameters like you would do with printf function
    int i=56;
    ExecuteSQL({call MyProc("MyString %d",i});



  3. #3
    Join Date
    Apr 1999
    Posts
    5

    Re: SQL Stored Procedures

    Hi,
    I am not sure about the format of the parameters in your codes, while it is possible to send parameters into a stored procedure using SQL API.
    Hope this will help.



    SQLRETURN retcode;

    TIMESTAMP_STRUCT dsDynamicCurDate;
    SQLINTEGER
    siIntRet;

    SQLINTEGER
    cbDynamicCurDate = 0,
    cbIntRet = 0;

    retcode = SQLPrepare(g_hstmt, (SQLCHAR*)
    "{call ? := guanj.PkgMorrowPlan.Plan2Dynamic( ? )}",
    SQL_NTS);


    if (retcode == SQL_SUCCESS)
    {

    SQLBindParameter(g_hstmt, 1, SQL_PARAM_OUTPUT, SQL_C_SLONG,
    SQL_INTEGER, 0, 0, &siIntRet, 0, &cbIntRet);

    SQLBindParameter(g_hstmt, 2, SQL_PARAM_INPUT, SQL_C_TIMESTAMP,
    SQL_TIMESTAMP, 0, 0, &dsDynamicCurDate, 0, &cbDynamicCurDate);


    COleDateTime dateTest = COleDateTime::GetCurrentTime();

    dsDynamicCurDate.year = dateTest.GetYear();
    dsDynamicCurDate.month = dateTest.GetMonth();
    dsDynamicCurDate.hour = dateTest.GetHour();
    dsDynamicCurDate.day = dateTest.GetDay();
    dsDynamicCurDate.minute = dateTest.GetMinute();
    dsDynamicCurDate.second = 0;
    dsDynamicCurDate.fraction = 0;

    retcode = SQLExecute(g_hstmt);

    if (retcode != SQL_SUCCESS)
    AfxMessageBox("Failed");
    }


  4. #4
    Join Date
    Jun 1999
    Location
    Seattle, WA
    Posts
    16

    Re: SQL Stored Procedures

    If you are working with SQL Server and MFC CDatabase classes try this:

    db.ExecuteSQL("EXEC YourProc 'stringarg', intarg");

    with "EXEC..."
    you should be able to finish it up with a call identical to the ones you type in iSQL.

    Software Engineer @ Interlinq Corp / Servicing Section

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured