SQL data connection not in all forms

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • samycbe
    New Member
    • Feb 2007
    • 83

    SQL data connection not in all forms

    Hi

    I have a sql server connection in my user login form_load...

    Con.CursorLocat ion = adUseClient
    Con.Open "Provider = SQLOLEDB.1;Pers ist Security Info=false;user ID=xxxx;pwd=yyy ;Initial catalog = ;Data Source = xxxx"

    it is working only in that form but it is not working in other forms. how to make it global. please help me ......

    samy
  • sashi
    Recognized Expert Top Contributor
    • Jun 2006
    • 1749

    #2
    Hi there,

    Add a module file file to your existing project and place the code segment under a function, as a shortcut you can call the function whenever you need to get connected to SQL server. Hope it helps. Good luck & Take care.

    Originally posted by samycbe
    Hi

    I have a sql server connection in my user login form_load...

    Con.CursorLocat ion = adUseClient
    Con.Open "Provider = SQLOLEDB.1;Pers ist Security Info=false;user ID=xxxx;pwd=yyy ;Initial catalog = ;Data Source = xxxx"

    it is working only in that form but it is not working in other forms. how to make it global. please help me ......

    samy

    Comment

    • vijaydiwakar
      Contributor
      • Feb 2007
      • 579

      #3
      Originally posted by samycbe
      Hi

      I have a sql server connection in my user login form_load...

      Con.CursorLocat ion = adUseClient
      Con.Open "Provider = SQLOLEDB.1;Pers ist Security Info=false;user ID=xxxx;pwd=yyy ;Initial catalog = ;Data Source = xxxx"

      it is working only in that form but it is not working in other forms. how to make it global. please help me ......

      samy
      put the code in module with public access specifier

      Comment

      • samycbe
        New Member
        • Feb 2007
        • 83

        #4
        I did that but shows an error like.....

        okject variable or with block variable not set

        Comment

        • samycbe
          New Member
          • Feb 2007
          • 83

          #5
          hi sashi....

          Its working now. Thanks.

          But i have one small doubt i am calling a function in all form_loads. Is it required?


          samy

          Comment

          • vijaydiwakar
            Contributor
            • Feb 2007
            • 579

            #6
            Originally posted by samycbe
            I did that but shows an error like.....

            okject variable or with block variable not set
            first defind the conn object there as public in module

            Comment

            Working...