473,406 Members | 2,371 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

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 5255
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****@discussions.microsoft.com> wrote in message
news:15**********************************@microsof t.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.Round(NakitDegerlerTP())
Row1Num2 = Math.Abs(Math.Round(NakitDegerlerYP())
Row1Num3 = Row1Num1 + Row1Num2
'Declare Excel object variables and create types
Dim xlApp As Excel.Application
Dim xlBook As Excel.Workbook
Dim xlSheet As Excel.Worksheet
xlApp = CType(CreateObject("Excel.Application"), Excel.Application)
xlBook = CType(xlApp.Workbooks.Add, Excel.Workbook)
xlSheet = CType(xlBook.Worksheets(1), Excel.Worksheet)
'Insert data
xlSheet.Range("E11").Cells.Formula = FormatNumber(Row1Num1, 0,
TriState.False, TriState.False, TriState.UseDefault)
xlSheet.Range("G11").Cells.Formula = FormatNumber(Row1Num2, 0,
TriState.False, TriState.False, TriState.UseDefault)
xlSheet.Range("I11").Cells.Formula = FormatNumber(Row1Num3, 0,
TriState.False, TriState.False, TriState.UseDefault)

'Display the sheet
xlSheet.Application.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
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...
2
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
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...
2
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...
1
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
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...
1
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...
0
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...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
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,...
0
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...
0
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...
0
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,...
0
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...

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.