A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook and VBA
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

SQL server integration with Outlook VBA



 
 
Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1  
Old April 18th 07, 06:34 PM posted to microsoft.public.outlook.program_vba
RosH
external usenet poster
 
Posts: 4
Default SQL server integration with Outlook VBA

Dear All,

I have been trying to integrate Outlook with an SQL database, even
though I am a newbie to SQL server databases. The following is the
procedure code that I used for inserting a new row into a table called
Accounts. The code is working fine, but a hunch from the back of my
head tells me the code is not efficient and not according to the best
practices because I rely on creation of a string to do the database
operations. I would like to represent it to the outlook experts here
who can guide me to learn the best way to connect, insert or update a
database from Outlook VBA. Thanks in advance

-------------------------CODE---------------------------

Public Sub SQLInsertNewAccount(ByVal objAccount As Accounts)

' Declarations
Dim Dbcon As New ADODB.Connection
Dim Dbcom As New ADODB.Command

' Initialisations
Dbcon.ConnectionString = "Provider=SQLOLEDB.1;Integrated
Security=SSPI;Persist Security Info=False;Initial Catalog=CRM;Data
Source=SERVER\SQLEXPRESS"
Dbcon.Open

' Command Object
Dbcom.CommandText = "INSERT INTO Accounts(RemoteID, OutlookID,
SyncStatus, Name, Address, City, PostalCode, Country, Phone, Fax,
WebPage, Description, Industry, EmployeeCount) VALUES ('" _
& objAccount.RemoteID & "', '" _
& objAccount.OutlookID & "', '" _
& objAccount.SyncStatus & "', '" _
& objAccount.Name & "', '" _
& objAccount.Address & "', '" _
& objAccount.City & "', '" _
& objAccount.PostalCode & "', '" _
& objAccount.Country & "', '" _
& objAccount.Phone & "', '" _
& objAccount.Fax & "', '" _
& objAccount.WebPage & "', '" _
& objAccount.Description & "', '" _
& objAccount.Industry & "', '" _
& objAccount.EmployeeCount & "')"


' Execution
Dbcom.ActiveConnection = Dbcon
Dbcom.Execute

' The End
Dbcon.Close
Set Dbcon = Nothing
Set Dbcom = Nothing

End Sub

 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
need a dev for small outlook/.net integration project professorhojo Outlook and VBA 0 March 30th 07 05:42 AM
Outlook 2007 And SharePoint Integration Sue Mosher [MVP-Outlook] Outlook and VBA 0 November 25th 06 05:02 AM
Is it possible to get Outlook 2003 Integration API from OOM or MAP Rui Feng Add-ins for Outlook 2 August 29th 06 09:10 AM
outlook and access data integration David Outlook - Using Forms 0 February 27th 06 04:22 PM
Integration of Outlook with Norton AntiSpam JohnM Outlook - General Queries 2 February 13th 06 08:16 PM


All times are GMT +1. The time now is 08:53 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.