• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 172
  • Last Modified:

Accessing Database using VBScript in Outlook

I'm used to using the DAO object in Visual Basic programs to access database tables.  I'm trying to create an Outlook form which reads in database information using VBScript.  Is this possible?  If yes, how?
0
cwirrgan
Asked:
cwirrgan
1 Solution
 
andcuCommented:
I think you must use ADO.  It's hardly any different from the actual coding point of view.  Similar properties/methods with similar names.
0
 
tkuppinenCommented:
If this is an internet application you could use ASP.   With ASP ADO is the inherent database access tool.
0
 
abwilesCommented:
result = GetJetConnection()
      if result <> 0 then exit function
 
      strSQL = "select * from Entities order by FundName"
      Set Entities = mydb.OpenRecordSet(strSQL,dbOpenSnapShot)
      do until Entities.EOF
            cmbJournalFunds.AddItem Entities("FundName")
            Entities.MoveNext
      loop

Function GetJetConnection

      on error resume next

      Dim strUser
      Dim strPass
      Dim dbDriverNoPrompt

      dbDriverNoPrompt = 1
      strUser = "sa"
      strPass = ""

      getJetConnection = 0

      Set dbe = Item.Application.CreateObject("DAO.dbEngine.35")
      if err.number <> 0 then
            msgbox err.description,16
            GetJetConnection = err.number
            exit function
      end if
      Set wrkJet = dbe.CreateWorkSpace("ODBCWorkSpace","admin","",dbUseJet)
      if err.number <> 0 then
            msgbox err.description, 16
            GetJetConnection = err.number
            exit function
      end if
      if not UseServer then
            Set mydb = wrkJet.OpenDatabase(DatabaseName,False)
      else
            ConnectStr = "uid=" & strUser & ";pwd=" & strPass & ";driver={SQL Server};Database=Marketing;server=" & ServerName
            Set mydb = wrkJet.OpenDatabase("",dbDriverNoPrompt,False,ConnectStr)
      end if

      if err.number <> 0 then
            msgbox err.description, 16
            GetJetConnection = err.number
            exit function
      end if

      DatabaseIsOpen = True

end function
0
 
cwirrganAuthor Commented:
Sorry about the delay, my home computer where I was working with Outlook died.  This answer got me going in the right direction.  Thanks
0

Featured Post

The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now