Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Excel VBA connection to SQL

Posted on 2011-09-12
2
Medium Priority
?
273 Views
Last Modified: 2012-08-13
Hi

I use the connection string in my code below to manipulate an online SQL database from Excel
I want to include a text box or other control that stays green while the databse can be connected to and turns red when it can't be connected to. What sort of VBA code would I use
to do this
Public Sub oAppend(ByVal oDate As Date, ByVal oText As String, ByVal oNumber As Single)
 
    Dim oSQL As String
    
    On Error GoTo EH
    
    Set con = New ADODB.Connection
    
    con.Open "Provider=SQLOLEDB;Data Source=196.11.247,1884;Network Library=DBMSSOCN;Initial Catalog=test;User ID=llllk3;Password=4lllgg;"

    Set cmd = New ADODB.Command

Open in new window

0
Comment
Question by:Murray Brown
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 17

Accepted Solution

by:
Shanmuga Sundaram earned 2000 total points
ID: 36524008
try using a timer object and that timerobject should check for connection status. if the connection state is 1 then you can make it as green and if the state is 0 then make it as red.
0
 

Author Closing Comment

by:Murray Brown
ID: 36544736
thanks
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Freeze panes is an option within all variants of Excel to enable parts of a sheet to remain stationary when the cursor is in another part of the sheet. This is a very useful feature which is overlooked or under used.
After seeing numerous questions for Dynamic Data Validation I notice that most have used Visual Basic to solve the problem. This suggestion is purely formula based and can be used in multiple rows.
This Micro Tutorial demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.
This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.

604 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question