Database Connection

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • nee123
    New Member
    • Aug 2006
    • 1

    #1

    Database Connection

    Hi Everybody
    I am tring to connect the vb code to ms access databse using ADO method.
    and its gives the Compile Error : user defined Data type is not defined.
    i have declared the following and complier highlights the declaration.

    Dim cn As ADODB.Connectio n

    Dim cmd As ADODB.Command

    please help
    Nee123
  • samah
    New Member
    • Aug 2006
    • 5

    #2
    Did you add ADO library to your project??

    Comment

    • ramesh_tankala
      New Member
      • Jul 2006
      • 10

      #3
      HI..
      PLZ TRY THE FOLOOWING POINTS
      1)ADD ADO LIBRARY
      2)Dim cn As NEW ADODB.Connectio n
      3)Dim cmd As NEW ADODB.Command

      BY
      RAMESH

      Comment

      • suresh_punniyakkodi
        New Member
        • Aug 2006
        • 20

        #4
        Hi,
        Please follow the following Steps,

        1. Projet menu -> Refences -> Select Microsoft ActiveX Data Objects 2.1 Library and click ok Button.

        2. Use the following code,

        Dim con As New ADODB.Connectio n
        Dim rs As New ADODB.RecordSet

        con.Open "Provider=Micro soft.Jet.OLEDB. 4.0;Data Source=D:\UserL ogin.mdb;Persis t Security Info=False"

        con.CursorLocat ion = adUseClient

        rs.Open "Login",con


        <<Here, Your database access code>>


        rs.Close
        con.Close

        Here,
        D:\UserLogin.md b -> DataBase Location
        Login -> Table Name

        Note:
        After finishing database access code you must close RecordSet(rs) and Connection(con) .

        Take Care,
        Bye... Bye...

        Comment

        • bhar
          Banned
          New Member
          • Apr 2006
          • 37

          #5
          Hi,

          Dim cn As ADODB.Connectio n

          Set cn=New ADODB.Connectio n
          cn.ConnectionSt ring="Provider= Microsoft.Jet.O LEDB.4.0;" & _
          "DataSource=D:\ ProgramFiles\Mi croSoft Visual Studio\VB98\inv entory.mdb"
          CN.Open

          Try This Title: "Develop an Inventory Management Application Uisng Microspft's Visual Basic" (Access as a backend)


          Hope this helps.

          Regards
          bhar




          Originally posted by nee123
          Hi Everybody
          I am tring to connect the vb code to ms access databse using ADO method.
          and its gives the Compile Error : user defined Data type is not defined.
          i have declared the following and complier highlights the declaration.

          Dim cn As ADODB.Connectio n

          Dim cmd As ADODB.Command

          please help
          Nee123

          Comment

          • AshishGupta
            New Member
            • Feb 2007
            • 1

            #6
            Thanks a lot for the code i m a new member and i was needing these code.
            thanks again

            Originally posted by suresh_punniyak kodi
            Hi,
            Please follow the following Steps,

            1. Projet menu -> Refences -> Select Microsoft ActiveX Data Objects 2.1 Library and click ok Button.

            2. Use the following code,

            Dim con As New ADODB.Connectio n
            Dim rs As New ADODB.RecordSet

            con.Open "Provider=Micro soft.Jet.OLEDB. 4.0;Data Source=D:\UserL ogin.mdb;Persis t Security Info=False"

            con.CursorLocat ion = adUseClient

            rs.Open "Login",con


            <<Here, Your database access code>>


            rs.Close
            con.Close

            Here,
            D:\UserLogin.md b -> DataBase Location
            Login -> Table Name

            Note:
            After finishing database access code you must close RecordSet(rs) and Connection(con) .

            Take Care,
            Bye... Bye...

            Comment

            Working...