Connection to Sql and Explicit declaration

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Jja
    New Member
    • Feb 2008
    • 1

    Connection to Sql and Explicit declaration

    Hello,

    I am very new to this site. before i start may i first introduce myself
    i am 'Jhalil, a beginner Vb6 programmer. i stumbled on this site on my
    quest for a code in vb that can connect me to either Microsoft sql or Mysql
    server. Infact i was suprised to see people with different programming
    problems. That is how i became a member of this good family.

    Now can anybody help? i am a beginner in VB 6, i enjoy writing codes
    but i do not know much of explicit declaration (option explicit), when i write
    codes, i do not decalare, i use only Dataenvironment for my connection, and
    my database is "Access" within Vb 6. Now my question:
    I have a project containing one form (frm1), Database name Jhalil, Table name
    is "Jjb", my database was created at c:\ directory. My form has three labels and
    three textfield, lblname,lbladdr ess, lblphone; and txtname,txtaddr ess, and txtphone respectively. Can anyone help me with a code to connect to this database which reside at c:\ "through option" explicit declaration.
  • jeffstl
    Recognized Expert Contributor
    • Feb 2008
    • 432

    #2
    Drag an ADO data control on to your form.

    Check the properties, and you will see that you can build a simple database connection from this control with the properties.

    If you want a more dynamic database connection you will have to probably have to declare your connection manually and check this site:

    www.connections trings.com

    Comment

    • Killer42
      Recognized Expert Expert
      • Oct 2006
      • 8429

      #3
      Hi Jja. Welcome to TheScripts. :)

      I'd just like to point out that you leave yourself open to a lot of problems by not using Option Explicit. Because allowing VB to automatically create variables any time you use them means that it will never tell you if you get a variable name wrong. This can make debugging your code very difficult. Take the following simple example...

      [CODE=vb]
      For iiiiiii = 1 To 5
      Debug.Print iiiiiiii
      Next
      [/CODE]
      If you think this would print the numbers 1 to 5, you've just demonstrated the very problem I was describing, because those are not the same variable. with Option Explicit set, VB would stop and tell you at compile time.

      Obviously I've exaggerated the issue here for illustrative purposes by using such an obscure variable name, but believe me, the problem does occur.

      Comment

      • Killer42
        Recognized Expert Expert
        • Oct 2006
        • 8429

        #4
        ayshamalik, your post constituted a new question, so I've split it off to it's own discussion thread. I should tell you though, you'll need to be more specific about things like what version of VB you're using, and exactly what you want to do. If it's just how to connect to Oracle, that has been covered tons of times. Try the Search button at the top, or just read the responses in this thread.

        Comment

        Working...