locked
Basic "If" syntax question RRS feed

  • Question

  • in the following code, I want to have the code go to this particular website, if the value is not PBS, it should go to a different site

     

    if this.customerDatabaseName.DatabaseName = "PBS",

     

    string url = "http://dr-wserver/DRWWebClient/Integration.aspx?i=healthtrack&lck=1233&p=RLV&q=" + query;

    else

    string url = "http://dr-wserver/theotherwebsite/Integration.aspx?i=healthtrack&lck=1233&p=RLV&q=" + query;

    Wednesday, June 30, 2010 5:06 PM

Answers

  • thankyou that is very good. there is one final error

    Error 5 The name 'url' does not exist in the current context C:\Documents and Settings\

    What I did it 1st: ?

     string url = String.Empty;

    • Marked as answer by tusharr Wednesday, June 30, 2010 8:47 PM
    Wednesday, June 30, 2010 7:24 PM

All replies

  • This is it, I hope it`s what you have wanted:

     

       string url = String.Empty;
       if (this.customerDatabaseName.DatabaseName == "PBS")
        url = "http://dr-wserver/DRWWebClient/Integration.aspx?i=healthtrack&lck=1233&p=RLV&q=" + query;
       else
        url = "http://dr-wserver/theotherwebsite/Integration.aspx?i=healthtrack&lck=1233&p=RLV&q=" + query;

     

    Wednesday, June 30, 2010 5:25 PM
  • string myurl="";

    if (this.customerDatabaseName.DatabaseName =="PBS")

     

    {myurl = "http://dr-wserver/DRWWebClient/Integration.aspx?i=healthtrack&lck=1233&p=RLV&q=" + query;}

    else

    { myurl = "http://dr-wserver/theotherwebsite/Integration.aspx?i=healthtrack&lck=1233&p=RLV&q=" + query;}

    Regards

     

     

    • Edited by Serguey123 Wednesday, June 30, 2010 6:50 PM
    Wednesday, June 30, 2010 5:26 PM
  • <form id="aspnetForm" action="edit" enctype="application/x-www-form-urlencoded" method="post"> <script type="text/javascript"></script> <script type="text/javascript"></script> <script type="text/javascript"></script> <noscript></noscript> <noscript></noscript></form>
    • Edited by tusharr Wednesday, June 30, 2010 6:52 PM
    Wednesday, June 30, 2010 6:44 PM
  • Perhaps the issue was the space between '=', I edited it, remember you need to compare using ==

    Let us know if this was the problem

    Regards

    Wednesday, June 30, 2010 6:52 PM
  • thankyou that is very good. there is one final error

    Error 5 The name 'url' does not exist in the current context C:\Documents and Settings\

    Wednesday, June 30, 2010 6:53 PM
  • you need to create the string to hold the data

    string url=""; //this is what you are missing

    if (this.customerDatabaseName.DatabaseName =="PBS")

     

    {url = "http://dr-wserver/DRWWebClient/Integration.aspx?i=healthtrack&lck=1233&p=RLV&q=" + query;}

    else

    { url = "http://dr-wserver/theotherwebsite/Integration.aspx?i=healthtrack&lck=1233&p=RLV&q=" + query;}

    Regards

    • Marked as answer by tusharr Wednesday, June 30, 2010 7:17 PM
    • Unmarked as answer by tusharr Wednesday, June 30, 2010 8:22 PM
    Wednesday, June 30, 2010 7:06 PM
  • Excellent, thank you for your help, I have learnt someting
    Wednesday, June 30, 2010 7:18 PM
  • here is another way to do it

    string dbName = this.customerDatabaseName.DatabaseName;
    string url = dbName == "PBS" ? 
        "http://dr-wserver/DRWWebClient/Integration.aspx?i=healthtrack&lck=1233&p=RLV&q=" + query :
        "http://dr-wserver/theotherwebsite/Integration.aspx?i=healthtrack&lck=1233&p=RLV&q=" + query;
    Wednesday, June 30, 2010 7:21 PM
  • thankyou that is very good. there is one final error

    Error 5 The name 'url' does not exist in the current context C:\Documents and Settings\

    What I did it 1st: ?

     string url = String.Empty;

    • Marked as answer by tusharr Wednesday, June 30, 2010 8:47 PM
    Wednesday, June 30, 2010 7:24 PM
  • HI THanks the code works, the web site is not showing records, but that can be a different issue.

    Wednesday, June 30, 2010 8:27 PM