473,700 Members | 2,311 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 5337
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
3718
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
1774
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
1118
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
1314
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
1267
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
1470
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
1095
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
8725
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, well explore What is ONU, What Is Router, ONU & Routers main usage, and What is the difference between ONU and Router. Lets take a closer look ! Part I. Meaning of...
0
9214
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9074
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
8970
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,...
1
6560
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupr who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5902
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
4403
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4656
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2027
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.