473,414 Members | 1,695 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,414 software developers and data experts.

Execute database to Excel exportation stored procedure from VB

Hi,

I have created two stored procedures via VB using this code:
sql = "CREATE PROC " & nombre_proc & " AS SELECT *" & _
" From MBM_PUNTOS_SCE_SIN_COINCIDIR_SIEGE_FALTA_PM_NE_" & mes & _
" WHERE (((IDU) Like 'czz*' Or (IDU) Like 'cam*' Or (IDU) _
Like 'szz*' Or (IDU) Like 'J*' Or (IDU) Like 'G*' Or (IDU) _
Like 'U*'))" & " ORDER BY IDU;"

conexion.Execute sql
sql = "CREATE PROC " & nombre_proc & " AS SELECT *" & _
" From MBM_PUNTOS_SCE_SIN_COINCIDIR_SIEGE_FALTA_PM_NE_" & mes & _
" WHERE (((IDU) Like 'czz*' Or (IDU) Like 'cam*' Or (IDU) _
Like 'szz*' Or (IDU) Like 'J*' Or (IDU) Like 'G*' Or (IDU) _
Like 'U*')=FALSE)" & " ORDER BY 1;"

conexion.Execute sql

If I open the Access database, the first stored procedure returns 123
records and the second returns 2 records, so both procedures seem to
work fine.

I then try to export the records to an Excel sheet via VB:

origen = nombre_proc
conexion.Execute _
"SELECT * INTO [Excel 8.0;DATABASE=" & NombreArchivo & _
"].[" & NombrePestańa & "] FROM " & "[" & origen & "]"

The result is the following:

- When I run the above code for the first stored procedure, the Excel
sheet only contains the captions of the columns, but not the 123
records.
- If I then run the code for the second stored procedure using another
destination sheet in the same workbook, then the second sheet contains
the 123 records that should have appeared in the first sheet and the 2
records that generates the second stored prodedure.

I have tried to execute the exportation sql statements directly from an
access query, and both work as expected, creating two sheets in the
same workbook (the first with 123 data rows and the second with two).

I have no idea about what I could be doing wrong. Anybody has seen this
behaviour before? What could be the reason?

Regards,
Fran

Dec 16 '05 #1
0 2300

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

Similar topics

2
by: Matt | last post by:
I want to exexute stored procedure in ASP, but it has error "Microsoft VBScript compilation (0x800A0401) Expected end of statement" on line (1). The stored procedure "sp_emp" contain "select *...
3
by: Zeke Hoskin | last post by:
Suddenly a stored procedure, very much like several others, is giving EXECUTE permission denied on object 'Add_Adjustment', database 'InStab', owner 'zhoskin'. server:Msg 229, Level 14, State 5,...
2
by: Eli | last post by:
Hi all We currently have a strange problem with calling a Stored Procedure (SQL Database) in our C# Project. The only error I get is "System error" which says a lot :) Background: We have...
8
by: Jiggaz | last post by:
Hi, In my ASPX Page, i have a form for signup. And whene user click on the button, the event Button1_Click must use a stored procedure. But instead of use stored proc, i get this exception :...
0
by: JoĂŁo Costa | last post by:
I am using the following funtion to export datagrids to xls: Public Shared Sub Exportar(ByVal dg As DataGrid) Dim g As New Guid Dim oResponse As System.Web.HttpResponse =...
3
by: Edbar | last post by:
SQL 7.0 Stored Procedure Execute Privileges Only? Does anyone know if a user/pass can be set up to give a sql 7.0 user stored procedure execute privileges only. That way, even if they get into...
14
by: technocrat | last post by:
db2 -t -v -f/home.../filename >output_file-name I have a java stored procedure..which has to run the above command...not sure how i can run this command through java.. any suggestions are...
5
by: alingsjtu | last post by:
Hello, every body. When execute dynamic generated multiple OPENQUERY statements (which linkes to DB2) in SQLServer, I always got SQL1040N The maximum number of applications is already connected...
1
by: PVBHANU | last post by:
Hi, I am using DB2 V9.1 windows , can any one please tell me how to complile and execute a stored procedure. I followed Alldatabse->database->Application Object->stored procedure...But No...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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 project—planning, coding, testing,...
0
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...

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.