Re: I must be really stupid......


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 4 of 4

Thread: Re: I must be really stupid......

  1. #1
    W. Pierce Guest

    Re: I must be really stupid......


    Here is what I did, and it still doesn't work. I either get error
    messages on the

    Activeconnection .Open "S:\Spare\Members.mdb"
    or I get error messages on the Sql string......

    Heres what I got....

    Public Sub Command6_Click()
    Dim strsql As String

    Set activeconnection = New Adodb.Connection
    activeconnection = "Microsoft.Jet.OLEDB.4.0"
    activeconnection .Open "S:\spare\members.mdb"
    Set rs = New Adodb.Recordset
    strsql = "select InmateNumber from members where InmateNumber=" & clng(txtInmateNum.Text)"


    End If

    End Sub




    "David" <david@cdsconsulting.mailbox.as> wrote:
    >
    >A Connection String is NOT a path to a database...
    >
    >Use this example as well as looking up Connection Strings in MSDN
    >
    >Use this code to first open your connection THEN run your sql string against
    >a table in this database
    >'**********************************************************************
    >'Open Database
    >'**********************************************************************
    >
    >Public Sub OpenRS()
    >'Establish conection to database
    >
    > Set ActiveConnection = New adodb.Connection
    > ActiveConnection .Provider = "Microsoft.Jet.OLEDB.4.0"
    > ActiveConnection .Open "S:\Spare\Members.mdb"
    > Set rs = New adodb.Recordset
    >
    >End Sub
    >
    >
    >PLUS, DELETE this from your previous code
    > Dim ActiveConnection As adodb.Connection
    >
    > Set ActiveConnection = New adodb.Connection
    > ActiveConnection.ConnectionString = "S:\Spare\Members.mdb"
    >
    >
    >
    >***********************************************************************
    >
    >



  2. #2
    David Guest

    Re: I must be really stupid......


    If you are getting errors on the SQL String then it's the string that's wrong...
    First..make sure there are no spaces between ActiveConnection and .Open and
    .Provider it should look like ActiveConnection.Open and ActiveConnection.Provider
    Second... do you have a table in your .mdb called members?? if so is it a
    hidden table? what version of Access are you using?
    You may have to replace "Microsoft.Jet.OLEDB.4.0" with "Microsoft.Jet.OLEDB.3.5"


    Give those a shot


    "W. Pierce" <piercewe@co.forsyth.nc.us> wrote:
    >
    >Here is what I did, and it still doesn't work. I either get error
    >messages on the
    >
    >Activeconnection .Open "S:\Spare\Members.mdb"
    >or I get error messages on the Sql string......
    >
    >Heres what I got....
    >
    >Public Sub Command6_Click()
    >Dim strsql As String
    >
    >Set activeconnection = New Adodb.Connection
    >activeconnection = "Microsoft.Jet.OLEDB.4.0"
    >activeconnection .Open "S:\spare\members.mdb"
    >Set rs = New Adodb.Recordset
    >strsql = "select InmateNumber from members where InmateNumber=" & clng(txtInmateNum.Text)"
    >
    >
    >End If
    >
    >End Sub
    >
    >
    >
    >
    >"David" <david@cdsconsulting.mailbox.as> wrote:
    >>
    >>A Connection String is NOT a path to a database...
    >>
    >>Use this example as well as looking up Connection Strings in MSDN
    >>
    >>Use this code to first open your connection THEN run your sql string against
    >>a table in this database
    >>'**********************************************************************
    >>'Open Database
    >>'**********************************************************************
    >>
    >>Public Sub OpenRS()
    >>'Establish conection to database
    >>
    >> Set ActiveConnection = New adodb.Connection
    >> ActiveConnection .Provider = "Microsoft.Jet.OLEDB.4.0"
    >> ActiveConnection .Open "S:\Spare\Members.mdb"
    >> Set rs = New adodb.Recordset
    >>
    >>End Sub
    >>
    >>
    >>PLUS, DELETE this from your previous code
    >> Dim ActiveConnection As adodb.Connection
    >>
    >> Set ActiveConnection = New adodb.Connection
    >> ActiveConnection.ConnectionString = "S:\Spare\Members.mdb"
    >>
    >>
    >>
    >>***********************************************************************
    >>
    >>

    >



  3. #3
    David Guest

    Re: I must be really stupid......


    Also your path to the database... since it's a network path you may have to
    use it's full network path such as "\\Server\folders\database"

    "W. Pierce" <piercewe@co.forsyth.nc.us> wrote:
    >
    >Here is what I did, and it still doesn't work. I either get error
    >messages on the
    >
    >Activeconnection .Open "S:\Spare\Members.mdb"
    >or I get error messages on the Sql string......
    >
    >Heres what I got....
    >
    >Public Sub Command6_Click()
    >Dim strsql As String
    >
    >Set activeconnection = New Adodb.Connection
    >activeconnection = "Microsoft.Jet.OLEDB.4.0"
    >activeconnection .Open "S:\spare\members.mdb"
    >Set rs = New Adodb.Recordset
    >strsql = "select InmateNumber from members where InmateNumber=" & clng(txtInmateNum.Text)"
    >
    >
    >End If
    >
    >End Sub
    >
    >
    >
    >
    >"David" <david@cdsconsulting.mailbox.as> wrote:
    >>
    >>A Connection String is NOT a path to a database...
    >>
    >>Use this example as well as looking up Connection Strings in MSDN
    >>
    >>Use this code to first open your connection THEN run your sql string against
    >>a table in this database
    >>'**********************************************************************
    >>'Open Database
    >>'**********************************************************************
    >>
    >>Public Sub OpenRS()
    >>'Establish conection to database
    >>
    >> Set ActiveConnection = New adodb.Connection
    >> ActiveConnection .Provider = "Microsoft.Jet.OLEDB.4.0"
    >> ActiveConnection .Open "S:\Spare\Members.mdb"
    >> Set rs = New adodb.Recordset
    >>
    >>End Sub
    >>
    >>
    >>PLUS, DELETE this from your previous code
    >> Dim ActiveConnection As adodb.Connection
    >>
    >> Set ActiveConnection = New adodb.Connection
    >> ActiveConnection.ConnectionString = "S:\Spare\Members.mdb"
    >>
    >>
    >>
    >>***********************************************************************
    >>
    >>

    >



  4. #4
    cappy Guest

    Re: I must be really stupid......


    >>strsql = "select InmateNumber from members where InmateNumber=" & clng(txtInmateNum.Text)"


    Try this:

    strsql = "select InmateNumber from members where InmateNumber=" & txtInmateNum.Text
    & ";"




Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center