Results 1 to 13 of 13

Thread: initializing variable

  1. #1

    Thread Starter
    Frenzied Member EyeTalion's Avatar
    Join Date
    Jul 2000
    Location
    New York
    Posts
    1,075

    initializing variable

    I have the code below in a module, but when I debug and check the value of strCon, the UserID and Password asre missing from the string, but when I put the cursor over origLogon and origPass they do have the correct values...how can I get the strCon variable to initilize?

    thanks


    VB Code:
    1. Public strCon As String = "Provider=MSDAORA;Password=" & origPass & ";User ID=" & origLogon & ";Data Source=dbatest"
    It's tough being an unhandled exception...

    ___________
    VB.NET 2008
    VB.NET 2010
    ORACLE 11g
    CRYSTAL 11

  2. #2
    Frenzied Member trisuglow's Avatar
    Join Date
    Jan 2002
    Location
    Horsham, Sussex, UK
    Posts
    1,536
    Looks fine to me. What data type are your origPass and origLogon variables? If they are strings then you shouldn't have a problem.
    This world is not my home. I'm just passing through.

  3. #3

    Thread Starter
    Frenzied Member EyeTalion's Avatar
    Join Date
    Jul 2000
    Location
    New York
    Posts
    1,075
    VB Code:
    1. Module Module2
    2. Public origLogon As String
    3. Public origPass As String
    4. Public strCon As String = "Provider=MSDAORA;Password=origPass;User ID=origLogon;Data Source=dbatest"
    5. Public objCon As New OleDbConnection(strCon)
    Last edited by EyeTalion; May 8th, 2003 at 10:41 AM.
    It's tough being an unhandled exception...

    ___________
    VB.NET 2008
    VB.NET 2010
    ORACLE 11g
    CRYSTAL 11

  4. #4
    Banished Cander's Avatar
    Join Date
    Dec 2000
    Location
    Why do you care?
    Posts
    6,913
    origLogon and origPass do not have values when strCon is populated. Thts why. It doesnt work the way you are thinking where if they are set later, that strcon is going to automatically change. Un uh. Doesnt do that.
    Stack Overflow
    See the features of Visual Studio 2010 and C# 4.0: The 10-4 show on Channel9

  5. #5

    Thread Starter
    Frenzied Member EyeTalion's Avatar
    Join Date
    Jul 2000
    Location
    New York
    Posts
    1,075
    is there a way I can go back and initilize strCon after I get values for the userid and password?
    It's tough being an unhandled exception...

    ___________
    VB.NET 2008
    VB.NET 2010
    ORACLE 11g
    CRYSTAL 11

  6. #6
    Banished Cander's Avatar
    Join Date
    Dec 2000
    Location
    Why do you care?
    Posts
    6,913
    yeah
    strCon = "Provider=MSDAORA;Password=" & origPass & ";User ID=" & origLogon & ";Data Source=dbatest"
    Stack Overflow
    See the features of Visual Studio 2010 and C# 4.0: The 10-4 show on Channel9

  7. #7

    Thread Starter
    Frenzied Member EyeTalion's Avatar
    Join Date
    Jul 2000
    Location
    New York
    Posts
    1,075
    ?
    It's tough being an unhandled exception...

    ___________
    VB.NET 2008
    VB.NET 2010
    ORACLE 11g
    CRYSTAL 11

  8. #8
    Banished Cander's Avatar
    Join Date
    Dec 2000
    Location
    Why do you care?
    Posts
    6,913
    whats confusing? You just set the variable again.
    Stack Overflow
    See the features of Visual Studio 2010 and C# 4.0: The 10-4 show on Channel9

  9. #9
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    If you can put your code in a class and build a constructor which is mainly created for intializing variables . Whenever you intantiate obj from this class , then you have to provide these two variables .

  10. #10
    Banished Cander's Avatar
    Join Date
    Dec 2000
    Location
    Why do you care?
    Posts
    6,913
    more work than necessary for something so simple.
    Stack Overflow
    See the features of Visual Studio 2010 and C# 4.0: The 10-4 show on Channel9

  11. #11

    Thread Starter
    Frenzied Member EyeTalion's Avatar
    Join Date
    Jul 2000
    Location
    New York
    Posts
    1,075
    whats confusing? You just set the variable again.
    but it's in my module, how do I call it?

    wait, I think it's beginging to sink in...just set the variable again in the form instead of the module?
    Last edited by EyeTalion; May 8th, 2003 at 12:31 PM.
    It's tough being an unhandled exception...

    ___________
    VB.NET 2008
    VB.NET 2010
    ORACLE 11g
    CRYSTAL 11

  12. #12
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083
    Cander is right but I thought of constructors as ideal option . strCon variable will hold the last value origLogon and origPass were set to ! It should work fine . And you can create two properties to set those two variables if you want .

  13. #13
    Lively Member
    Join Date
    Feb 2003
    Location
    UK
    Posts
    95
    Originally posted by Cander
    more work than necessary for something so simple.
    VB.NET is an OO language it should go in a class however simple.

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