SPONSORS:






User Tag List

Thanks Thanks:  0
Likes Likes:  0
Dislikes Dislikes:  0
Results 1 to 2 of 2
  1. #1
    Junior Member
    Join Date
    Sep 2004
    Location
    Sacramento
    Posts
    18
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Rational coding question...

    I am trying to figure out a way to make my script self-saficient, meaning I don't want to have to maintain it. I want the user to be able to input there DSN (Data Source Name in the ODBC connection) and database name and have the script use those variables as part of it's code. Here's an example of what I'm trying to do exactly:
    '**********************************************
    'Make a backend SQL DB connection******
    'open the connection
    connection = SQLOpen("DSN=qaqc-billing; UID=sa; PWD=",prompt:=4)

    'Get the RunNum variable
    query = "SELECT BLSTGKEY FROM QAQC_Billing.IMSV7.BLSTG ORDER BY BLSTGKEY DESC"

    RetCode = SQLExecQuery(connection,query)

    RetCode = SQLRetrieve(connection:=connection,destination:=de stination(),columnNames:=0,rowNumbers:=0,maxRows:= 1,maxColumns:=1,fetchFirst:=0)

    RunNum=destination(1,1)

    RetCode = SQLClose(connection)

    Print RunNum
    '***********************************************
    Whenever it calls on qaqc-billing or qaqc_billing those are my DSN and db names respectively. I want the user to be able to enter there DSN and db name instead of having to update the scripts every time the db changes...which is highly possible.

    Is there a way to do this?

    I tried this:
    '**********************************************
    'Get the DSN ODBC connection name
    msgtext="Enter the DSN of the ODBC connection:"

    datasourcename=InputBox$(msgtext)

    'Get the database name
    msgtext="Enter the database name:"

    databasename=InputBox$(msgtext)

    'Make a backend SQL DB connection******
    'open the connection
    connection = SQLOpen("DSN=(datasourcename); UID=sa; PWD=",prompt:=4)

    'Get the RunNum variable
    query = "SELECT BLSTGKEY FROM (databasename).IMSV7.BLSTG ORDER BY BLSTGKEY DESC"

    RetCode = SQLExecQuery(connection,query)

    RetCode = SQLRetrieve(connection:=connection,destination:=de stination(),columnNames:=0,rowNumbers:=0,maxRows:= 1,maxColumns:=1,fetchFirst:=0)

    RunNum=destination(1,1)

    RetCode = SQLClose(connection)

    Print RunNum
    '***********************************************
    But this is not working for me. I may have to use these {} or something like that instead of the parenthesis around my variables.

    I have tried {variable}, ("variable"), (variable), "variable". I have to also take into consideration that this may not be allowed in Rational Robot?

    Thanks in advance for any input!

  2. #2
    Junior Member
    Join Date
    Sep 2004
    Location
    Sacramento
    Posts
    18
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Rational coding question...

    Nevermind, I finally answered the question myself. This is how I solved it in case you wanted to know...

    'Make a backend SQL DB connection******
    'open the connection
    connection = SQLOpen("DSN=" & datasourcename & "; UID=sa; PWD=", prompt:=4)

    'Get the RunNum variable
    query = ("SELECT BLSTGKEY FROM " & databasename & ".IMSV7.BLSTG ORDER BY BLSTGKEY DESC")

    RetCode = SQLExecQuery(connection,query)

    RetCode = SQLRetrieve(connection:=connection,destination:=de stination(),columnNames:=0,rowNumbers:=0,maxRows:= 1,maxColumns:=1,fetchFirst:=0)

    RunNum=destination(1,1)

    RetCode = SQLClose(connection)

    Print RunNum


    I knew there was a way, just had to find it... [img]images/icons/smile.gif[/img]

 

 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Search Engine Optimisation provided by DragonByte SEO v2.0.36 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Resources saved on this page: MySQL 12.00%
vBulletin Optimisation provided by vB Optimise v2.6.4 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
User Alert System provided by Advanced User Tagging v3.2.8 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
vBNominate (Lite) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Feedback Buttons provided by Advanced Post Thanks / Like (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Username Changing provided by Username Change (Free) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
BetaSoft Inc.
Digital Point modules: Sphinx-based search
All times are GMT -8. The time now is 05:31 AM.

Copyright BetaSoft Inc.