![]() |
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. |
|
|
Thread Tools | Search this Thread | Display Modes |
#1
|
|||
|
|||
![]()
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 |
Ads |
#2
|
|||
|
|||
![]() For the database it doesn't matter if the data comes from Outlook, more important is how much data it is and how often it will come in. Best pratice depends on the environment, network; do you need transactions, security etc. and would better be discussed in a database related newsgroup. -- Viele Gruesse / Best regards Michael Bauer - MVP Outlook Quick-Cats - Categorize Outlook data: http://www.vboffice.net/product.html...&lang=en&pub=6 Am 18 Apr 2007 09:34:57 -0700 schrieb RosH: 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 |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
need a dev for small outlook/.net integration project | professorhojo | Outlook and VBA | 0 | March 30th 07 04:42 AM |
Outlook 2007 And SharePoint Integration | Sue Mosher [MVP-Outlook] | Outlook and VBA | 0 | November 25th 06 04: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 08:10 AM |
outlook and access data integration | David | Outlook - Using Forms | 0 | February 27th 06 03:22 PM |
Integration of Outlook with Norton AntiSpam | JohnM | Outlook - General Queries | 2 | February 13th 06 07:16 PM |