Results 1 to 4 of 4
  1. #1
    Join Date
    Sep 2003
    Posts
    23

    Unanswered: Access/Ado/VbScript simple problem

    Hi,
    I am having a problem with VBScript and ADO. What I am trying to do is to get information from
    a table in an Access database and populated it into a combobox in an Outlook custom form.
    My problem is simple but I can find why the recordset cannot be set. I am using that script editor
    in Microsoft Outlook XP.
    The Connection is working but I am not getting any data from my recordset. And my table is definately full
    of data. Does anybody knows what could be wrong in my code.
    Could it be a access security issue? Do I have to put a Password and username in my connection string?

    Here's my code:

    ''''''''''''''''''''''''''''''''

    Function Item_Open()

    Const adStateClose = 0
    Const adStateOpen = 1
    Const adOpenDynamic = 2
    Const adLockOptimistic = 3
    Const adCmdTableDirect = 512

    dim cn
    dim rs
    dim errorObject
    dim strConnection
    dim sTemp

    Set FormPage = Item.GetInspector.ModifiedFormPages("Feuille de temps")
    Set Control = FormPage.Controls("cboProjet")

    Set cn = CreateObject("ADODB.Connection")
    Set rs = CreateObject("ADODB.Recordset")
    Set errorObject = CreateObject("ADODB.Error")

    On Error Resume Next

    strConnection = "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Documents and Settings\Projects.mdb"

    cn.open strConnection

    if cn.State = adStateOpen then
    msgbox "Connected"
    elseif cn.State = adStateClosed then
    msgbox "Not connected"
    end if

    Set rs = cn.Execute("Select * from tbl_Projects")

    if rs.EOF and rs.BOF Then
    msgbox("No")
    else
    msgbox("yes")
    end if

    'rs.Open "Select * from tbl_Projets", cn, adOpenDynamic, adLockOptimistic, adCmdTableDirect
    'sTemp = rs("Description")
    'msgbox sTemp

    ErrProcess
    rs.Close
    cn.Close

    End Function

    Sub ErrProcess()

    For each erroObject In rs.ActiveConnection.Errors
    msgbox "Description: " & errorObject.Description & Chr(10) & Chr(13) & _
    "Number: " & Hex(errorObject.Number)
    Next

    End Sub
    '''''''''''''''''''''''''''''''''''''''''''''''''' '''''''''''
    Thanks in advance.

  2. #2
    Join Date
    Mar 2004
    Location
    www.scirocco.ca
    Posts
    346
    Instead of

    Set rs = cn.Execute("Select * from tbl_Projects")

    Try

    rs.Open "Select * from tbl_Projects", cn
    http://www.scirocco.ca/images/banner...occobanner.gif

    Download for FREE the ADO/DAO Data Controls that makes life EASIER developing database applications in: VB, FoxPro, Access, VC++, .NET etc... Navigate, Add New, Delete, Update, Search, Undo and Save your changes. Supports Disconnected Recordsets and Transactions!

    Or try our Ask An Expert service to answer any of your questions!

  3. #3
    Join Date
    Sep 2003
    Posts
    23

    Access/Ado/VbScript simple problem

    Hi,
    I have already tried that. The thing is that I am using a mdw access file for the security. The connection is open but I still cannot see me recordset. I do not know if it has to do with my security in my MDW. Could it be a security problem?
    I have try these 2 others connections string this but it does not seems to work.

    strConnection = "PROVIDER=Microsoft.Jet.OLEDB.4.0; " & _
    "Data Source=C:\Documents and Settings\Projects.mdb;" & _
    "Jet OLEDBystemDatabase=c:\My.MDW;" & _
    "User Id=admin;Password=;"

    and this one with a DSN

    "Provider=MSDASQL;" & _
    "Driver={Microsoft Access Driver (*.mdb)};" & _
    "Dbq=C:\Documents and Settings\Projects.mdb;" & _
    "Uid=admin;" & _
    "Pwd="

    My connection is created but nothing is return in the recordset.

    Do you have an idea about my issue? thanks

  4. #4
    Join Date
    Sep 2003
    Posts
    23

    Post ADO/Access/vbscript

    I was finally able to make the thing work but it is strange. Anyway, it was due to the connection string security. Here's the answer:

    strConnection = "PROVIDER=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Documents and Settings\Projets.mdb;User ID=Admin;Password=;

    The thing that's wrong with this string is that I am using a MDW Group administration security and it is not even checking it. I was putting that line before the Data Source but it was giving me an error:

    "Jet OLEDBystemDatabase=H:\GOD\Moderco.MDW;" & _

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •