Can Teradata tables be updated in an VB.NET application by reading an Excel spreadsheet and pulling certain values from certain columns? If so how?
Yes.
This link shows how to read from a server database and update Excel, via ADO.NET and two OleDb connections.
It should be easy to modify that code to do the reverse. ; you'd just need to swap the connection strings shown in that code, so that the source is Excel, and the destination is your Teradata db.
There are some Excel-specific things in the queries, but you get the idea.
NB: This is not Excel Automation. It uses ADO.NET to read/update an Excel sheet. You don't need Excel to be installed on the machine in order to do these queries.
Related
I currently have a package that creates an excel spreadsheet with multiple tabs, and it names each column in each tab. Later in the package, I have excel connections that select my data using queries and populates each column in each tab based on the mappings I define. This has worked for a long time, but since a driver update, my OLE DB connections wont let me create the excel spreadsheet anymore. The key here is that the package needs to be able to be called by a scheduling system and be totally hands off and self sufficient. Also, the excel spreadsheet is created brand new with every execution of the package so we can keep an archive of old reports.
I've tried to use the existing excel connections to also build the spreadsheet, but I don't see a way to populate multiple tabs in the same spreadsheet with excel connections.
Is there a better way to do this without having to do a C# script.
My skill level: basic user of VBA, know next to nothing about SQL (though I’ve recently learned how to execute code, etc).
I’ve created a user interface in an Excel worksheet to allow user input of report variables (dates, etc). These pass into a second Excel worksheet that, through the use of various Excel statements, creates the necessary SQL code. My macro then copies this worksheet and opens Microsoft SQL Server 2008 Rx via a shell command. Currently, I then manually click “connect” on the resultant Microsoft SQL Server 2008 R2 connect-to-server window (which does not need a password, just requires me to click “connect”), I create a new query, I paste the code in and then execute in SQL. So it is these latter steps (opening SQL, click “connect”, copy/paste code, execute) that I’m trying to automate via VBA.
To offer more context, once the SQL code has run, I then have a second macro that uses the Excel Data Connection wizard to bring the resultant SQL data back into my worksheet. This is working well.
I’ve researched this for several days on various boards. None seem to observe my approach of creating the code in Excel (probably because it is an inelegant approach). Or the post responses are beyond my skill level to understand. But I do fear that I’m asking a question that has been answered before (apologies in advance).
Thanks for whatever advice/time can be offered.
I’m using:
Excel/Office 2010
Microsoft SQL Server2008 R2 (is this the same as Microsoft SQL Server Management Studios? My SQL application shows both names)
Microsoft ActiveX Data Objects 6.1 Library (this is NOT currently checked off. One post I saw referenced the need for this. I have multiple prior AciveX Library versions available as well.)
What you're doing is very ingenious, but it's probably not necessary. Excel has a number of features for importing external data.
I would look at the Data tab in Excel and the From Other Sources section of the ribbon. You have at least three options: the From SQL Server, From Data Connection Wizard, and From Microsoft Query options.
All of these will set up a connection to a database server and execute SQL against it. They return data to your spreadsheet in different ways.
Where VBA will come into play again is in automating the generation and parameterization of the queries these will execute.
But I would set up something that works, with constants for your parameter values, first, so you get an idea of the possibilities, and then read and research dynamically setting your SQL with VBA.
You might also investigate PowerPivot, by the way.
I am trying to make an application in VB6.0 using MS Excel as database. I have some textboxes on my VB Form to take input from user. I want to store those values in an Excel file. There will be another form where I want to retrieve the values from Excel and display it in textbox/labels.
Can I use SQL queries for inserting/retrieving the values while using Excel as database?
I just need a sample code for understanding the process. Rest I will try to manage.
Thanks in advance.
It's a poor idea.
While you can treat an Excel workbook as a data source via the Jet IISAM or ODBC Desktop Driver this is really meant for simple importing and exporting and has numerous limitations.
Save yourself some grief and just use Jet 4.0 to create and make use of MDB files. No MS Access is required, Jet 4.0 comes preinstalled and has for a rather long time now.
I want to create Windows based inventory application. I need to automate the manual entry in multiple excel spreadsheets, and in spreadsheet formula's are also used . values in sheets are interdependent upon formulas.
I want to use excel like tables and formulas in application. Is there any way of creating spreadsheet and assigning formula's to cell ?
Or Any better alternative?
As Tony suggests using a databse is a far better idea. If you use a database then you can have excel sheets connect to this for other users to interact with.
Can you connect to sql server from Excel?
I am storing data in a backend database (PostgreSQL) which is running on a Linux machine. I want to be able to fetch data from the database, and populate a sheet in an excel workbook, so that I can carry out analysis in Excel.
It has been quite a while since I wrote anything in VBA, so I would appreciate some help (or links) in getting started. I would like to know the best way to approach this:
Pure VBA solution OR
Mixture of C# or other .Net language for data extraction logic and VBA for manipulating Excel objects (sheet data population etc)
Any ideas, tips, snippets and/or links that can help me get started on the twin objectives:
fetching data from a backend database (PostgreSQL) into Excel
populating a specified sheet in Excel with the columnar data retreived from the database
will be much appreciated.
If you are just trying to import data, Excel can do that without additional code. Just set up your windows client to connect to your postgreSQL server thru ODBC. (Here's one way guide to setting that part up: enter link description here
Then in Excel (Use a modern version, like 2007 or greater) from the "Data" tab, click on "Existing Connections" to connect to the ODBC connection you set up and pick the tables/data to import into excel. Once the spreadsheet has loaded the data, you can just click the "Refresh All" button to update the data.