473,657 Members | 2,380 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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_S IEGE_FALTA_PM_N E_" & 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.Execut e sql
sql = "CREATE PROC " & nombre_proc & " AS SELECT *" & _
" From MBM_PUNTOS_SCE_ SIN_COINCIDIR_S IEGE_FALTA_PM_N E_" & 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.Execut e 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.Execut e _
"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 2322

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

Similar topics

2
13613
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 * from Employee;" <% Dim objRS, sqlStmt set objRS = Server.CreateObject("ADODB.Recordset") Dim conn Set conn = Server.CreateObject("ADODB.Connection")
3
13048
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, Procedure Add_Adjustment, Line 18. I'm zhoskin. I am the dbo and created the procedure, and when I look at its properties, I have EXEC permission. Line 18 is just the return statement. The values are all appropriate for the table. So what is...
2
3326
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 several stored procedures to Insert and update datas in our SQL database. Some stored procedures are smaller (insert datas in only one table) and some of them are quite big (insert datas in several
8
9557
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 : _____ System.Data.SqlClient.SqlException: EXECUTE permission denied on object 'CreateAccount', database 'wizou', schema 'dbo'. at
0
922
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 = System.Web.HttpContext.Current.Response oResponse.Clear() oResponse.AddHeader("Content-Disposition", "attachment; filename=Exportador" + g.NewGuid.ToString + ".xls") oResponse.ContentType = "application/vnd.ms-excel"
3
1828
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 the database, they can do nothing except run the stored procedures. Thanks, Ed
14
11137
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 appreciated..
5
12258
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 to the database. SQLSTATE=57030. Background: I created a linked server to DB2 8.1 database which called GRR_DB2Server. In my stored procedure p_FetchRawData, I need to read some data from this linked server GRR_DB2Server and insert them into
1
2065
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 Use... i have following simple stored procedure.. create procedure test(in value1 int,in value2, out value3) begin
0
8394
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, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8605
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
7327
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, and deployment—without 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...
1
6164
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
5632
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
4152
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...
1
2726
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
2
1955
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1615
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.