Solved

Excel - editing data in an online SQL table

Posted on 2011-09-07
2
183 Views
Last Modified: 2012-06-27
Hi

I used the following code (recorded as a macro) to import a table from an online SQL database
I want the user to edit certain cells and have these changes also happen in the database.

How could I achieve this?

Thanks
Sub Macro1()
'
' Macro1 Macro
'

'
    With ActiveSheet.ListObjects.Add(SourceType:=0, Source:=Array( _
        "OLEDB;Provider=SQLOLEDB.1;Persist Security Info=True;User ID=Gnnn;Data Source=123.220.43.247,6644;Use Procedure for Prepare=1;Auto " _
        , _
        "Translate=True;Packet Size=4096;Workstation ID=USER-PC;Use Encryption for Data=False;Tag with column collation when possible=Fal" _
        , "se;Initial Catalog=psql"), Destination:=Range("$A$1")).QueryTable
        .CommandType = xlCmdTable
        .CommandText = Array("""psql"".""Graham2"".""Performance""")
        .RowNumbers = False
        .FillAdjacentFormulas = False
        .PreserveFormatting = True
        .RefreshOnFileOpen = False
        .BackgroundQuery = True
        .RefreshStyle = xlInsertDeleteCells
        .SavePassword = False
        .SaveData = True
        .AdjustColumnWidth = True
        .RefreshPeriod = 0
        .PreserveColumnInfo = True
        .SourceConnectionFile = _
        "C:\Users\User\Documents\My Data Sources\196.220.43.247,1444 psql Performance.odc"
        .ListObject.DisplayName = "Table__196.250.43.247_1411_psql_Performance"
        .Refresh BackgroundQuery:=False
    End With
    ActiveCell.FormulaR1C1 = "Date"
    Range("D10").Select
End Sub

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 10

Accepted Solution

by:
Makrini earned 500 total points
ID: 36501549
It *can* be done, but requires some significant VBA and Sql knowledge.   If you have another option, use it.

  Having said that - here is a reference if you are willing to start to learn it

http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=49926

0
 

Author Closing Comment

by:Murray Brown
ID: 36510323
thanks a lot
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

How to get Spreadsheet Compare 2016 working with the 64 bit version of Office 2016
If you need to forecast numbers -- typically for finance -- the Windows and Mac versions of Excel 2016 have a basket of tools to get the job done.
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.
This Micro Tutorial will demonstrate how to create pivot charts out of a data set. I also added a drop-down menu which allows to choose from different categories in the data set and the chart will automatically update.

630 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