473,595 Members | 2,456 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Excel, DB2, AS400 (retriving data and sending into Excell)

Hi,

I have to retrieve a data from AS400 DB2 and after working with data I have
to export into one of existing Excel file.

I can connect into specific library in AS400 DB2 using AS400 Client-Access
v5.2 program using (in VB.NET) ODBC driver (DSN Name …) . I can retrieve
datam work on it using VB.NET and I can send into 'NEW' Excel file.

My first problem starts here:
1- Every time I access in to DB2 I open the connection to retrieve the data
from specific table and close the connection.
2- Every connection I use SQL command such as SUM. AVG etc. Most of the time
(%90) retrieving the data from AS400 DB2 takes some time. (between 15second
to 55 second)
3- I have to do this operation at least 50 times at most.
4- I am using VB.NET to achieve this operation.

My first question is:
- I want to put some information on label which resides on main Form that
shows user about current activity. Such as (“Retrieving data for DEN60”….)
and so on.
I have 50 tables that I have to get their sum, avg, or something similar. So
I want some information that tells user what the program is doing.
Unfortunately I do not know how to achieve it?

Now my second problem is this:
1- I have a pre-define Excel file and has only one worksheet and its tab it
show AC2004 instead of Sheet1.
2- I have to send some data into this sheet (respectively into E11, G11 and
I11 cells)
3- After sending the data I have to close the Excel and warn the user that
data save into existing Excel file.
Again I do not know how to do this.

I search and study about Excel Object. So I can retrieve data from AS400 DB2
and send the data into any cell in new excel file but I am having difficulty
to achieve same operation when the end result must be existing excel file in
specific sheet and specific cell.

I thank you in advance that finding time to read my post and I hope you
might find time to help me.

Regards.
Niyazi
Jul 21 '05 #1
2 5306
there are two ways to put data into Excel, that I know of -
- using automation (Excel object model)
- using ADO.NET - treating Excel as a database.

For the latter,
using the Jet OLEDB provider for Excel, you can refer to a named range like
this:

select * from [materials$]

eg, http://tinyurl.com/6yglu

or you can Create a sheet by running a CREATE TABLE command - the sheet is
the name you provide for the table.
for the former, there are lots of examples, I think you can find one in the
..NET SDK quickstart which is optionally installed when you install the .NET
SDK.

-D


"Niyazi" <Ni****@discuss ions.microsoft. com> wrote in message
news:15******** *************** ***********@mic rosoft.com...
Hi,

I have to retrieve a data from AS400 DB2 and after working with data I
have
to export into one of existing Excel file.

I can connect into specific library in AS400 DB2 using AS400 Client-Access
v5.2 program using (in VB.NET) ODBC driver (DSN Name .) . I can retrieve
datam work on it using VB.NET and I can send into 'NEW' Excel file.

My first problem starts here:
1- Every time I access in to DB2 I open the connection to retrieve the
data
from specific table and close the connection.
2- Every connection I use SQL command such as SUM. AVG etc. Most of the
time
(%90) retrieving the data from AS400 DB2 takes some time. (between
15second
to 55 second)
3- I have to do this operation at least 50 times at most.
4- I am using VB.NET to achieve this operation.

My first question is:
- I want to put some information on label which resides on main Form that
shows user about current activity. Such as ("Retrieving data for DEN60"..)
and so on.
I have 50 tables that I have to get their sum, avg, or something similar.
So
I want some information that tells user what the program is doing.
Unfortunately I do not know how to achieve it?

Now my second problem is this:
1- I have a pre-define Excel file and has only one worksheet and its tab
it
show AC2004 instead of Sheet1.
2- I have to send some data into this sheet (respectively into E11, G11
and
I11 cells)
3- After sending the data I have to close the Excel and warn the user that
data save into existing Excel file.
Again I do not know how to do this.

I search and study about Excel Object. So I can retrieve data from AS400
DB2
and send the data into any cell in new excel file but I am having
difficulty
to achieve same operation when the end result must be existing excel file
in
specific sheet and specific cell.

I thank you in advance that finding time to read my post and I hope you
might find time to help me.

Regards.
Niyazi

Jul 21 '05 #2
Hi Dino,

I already connected AS400 and I retrive the data and I can send into newly
created Excel sheet. My problem is how to send the data into exsiting Excel
sheet?

Here is my code
------------------------------------------------------------------------------------------------
'READ NAKIT DEGERLER and CALCULATE (1)
Dim Row1Num1, Row1Num2, Row1Num3 As Integer
Row1Num1 = Math.Abs(Math.R ound(NakitDeger lerTP())
Row1Num2 = Math.Abs(Math.R ound(NakitDeger lerYP())
Row1Num3 = Row1Num1 + Row1Num2
'Declare Excel object variables and create types
Dim xlApp As Excel.Applicati on
Dim xlBook As Excel.Workbook
Dim xlSheet As Excel.Worksheet
xlApp = CType(CreateObj ect("Excel.Appl ication"), Excel.Applicati on)
xlBook = CType(xlApp.Wor kbooks.Add, Excel.Workbook)
xlSheet = CType(xlBook.Wo rksheets(1), Excel.Worksheet )
'Insert data
xlSheet.Range(" E11").Cells.For mula = FormatNumber(Ro w1Num1, 0,
TriState.False, TriState.False, TriState.UseDef ault)
xlSheet.Range(" G11").Cells.For mula = FormatNumber(Ro w1Num2, 0,
TriState.False, TriState.False, TriState.UseDef ault)
xlSheet.Range(" I11").Cells.For mula = FormatNumber(Ro w1Num3, 0,
TriState.False, TriState.False, TriState.UseDef ault)

'Display the sheet
xlSheet.Applica tion.Visible = True

'Save the sheet to C:\Test\1-BL100-A.XLS
xlSheet.SaveAs( "C:\Test\1-BL100-A.XLS")
' Close Workbooks and Close the Excel Application.
xlApp.Workbooks .Close()
xlApp.Quit(
------------------------------------------------------------------------------------------------

I have a Excel document namerd as 1-BL100-A.XLS. Now I have to open this
excel sheet and send data into it. But I have to send into E11, G11 and I11
cell.

Yes I used Excel object model but when I try to send data into this existing
excel sheet it doesn't show other information but it goes and creates as a
new sheet.

I want to open this excel sheet and sent into the data, can you be kind
enough to help me. The link you provide didn't work. It is showing some C#
code but I am using VB.NET

Thank you.

Regards,
Niyazi
Jul 21 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
3709
by: Niyazi | last post by:
Hi, Our company uses IBM AS400 and DB2 (version 4.5 I guess). I have to do some report but I donot know how to access the AS400 DB2. I search IBM unfortunately IBM site in mess. Can anyone tell me how to access AS400 DB2 so I can use VB.NET for my application to create a report? I also learn from IBM site that there is a DB2 Data Connection for Visual Studio.Net and acts as IBM Explorer in conjunction with Server Explorer and toolbar...
2
1763
by: | last post by:
Greets, How does one connect to a local excel file using data wizard is it possible? I'm trying to connect to an excel file and populate a dataset and combo box with the data from excel TIA
0
1104
by: dzemo | last post by:
Which is the fastest way to "pump" data into crystal report in vb.net 2003? Is it: 1. content report as set datasource to dataset and filter data on fill dataset 2. set an output file and set connection direct to server and use selection formula to filter data 3. use odbc or something else I'll have a grate amount of data (over 1000000 records in one year) thx
2
527
by: Niyazi | last post by:
Hi, I have to retrieve a data from AS400 DB2 and after working with data I have to export into one of existing Excel file. I can connect into specific library in AS400 DB2 using AS400 Client-Access v5.2 program using (in VB.NET) ODBC driver (DSN Name …) . I can retrieve datam work on it using VB.NET and I can send into 'NEW' Excel file. My first problem starts here:
1
1309
by: sp | last post by:
i have an xml file <catalog> <cd> <title>Empire Burlesque</title> <artist>Bob Dylan</artist> <country>USA</country> <company>Columbia</company> <price>10.90</price> <year>1985</year>
0
1263
by: beebelbrox | last post by:
Greetings all. Once more I must dip into the font of your collective wisdom and request help: I have been given the task of taking an exsisting Access Query and exporting it to excel. There are hitches. The query has two groups of records "A" and "B". The excel spread sheet needs to display Group "A" followed by the subtotals for select fields. Next a little white space then Group "B", again followed by sub totals. With Grand totals...
1
1456
Ali Rizwan
by: Ali Rizwan | last post by:
Hi all, I m creating a database. The data for database will fetched from an excell sheet. Now how can i read an excell sheet and update my database with that excell sheet. Or I want to show all records of excell sheet in a listbox having a title of speecific text like "Names". Thanx >> ALI <<
0
1087
by: pchaitanya | last post by:
hi all, suppose in a table if i have columns namely name,entrydate now on retriving and binding to a gridview how can I get names rowwise and entrydate columnwise on a gridview on Xaxis I want entrydate and yaxis names in following format -----------------------------------------------------------------------------------
0
7883
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8379
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8020
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8252
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6675
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development projectplanning, coding, testing, and deploymentwithout human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5421
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
3915
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2391
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1491
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.