PC SOFT

FORUMS PROFESSIONNELS
WINDEVWEBDEV et WINDEV Mobile

Accueil → WINDEV 2024 → Stored Procedure SQL OLEBD - Problem to Get result dataset
Stored Procedure SQL OLEBD - Problem to Get result dataset
Débuté par V.Herbert, 12 jan. 2018 12:40 - Aucune réponse
Posté le 12 janvier 2018 - 12:40
Hello,

I have an issue to retrieve he dataset of a stored procedure in WINDEV19.
The error message says that the "data source is not initialized"

- Connection SLQ SERVER OLEDB: HDescribeConnection(gs_CommonDB_Connection,gs_sql_user,gs_sql_password,gs_server_name,gs_AIGCOMMONDB_Name,hOledbSQLServer,hOReadWrite)

I looked on all forums and tried various samples without success.
Can someone help ?
Many thanks in advance.

WINDEV code:

gs_SQLstring = [
DECLARE @@ret BIGINT ;
USE [AigCommonDb]
EXECUTE @@ret=[AigCommonDb].[dbo].[sp_getProfile_Minerva]
@userName = N'%1'
]

gs_SQLstring = StringBuild(gs_SQLstring, "vandera")

IF HExecuteSQLQuery(qry_file_CommonDB, gs_CommonDB_Connection, ...
hQueryWithoutCorrection,gs_SQLstring ) THEN
IF ErrorOccurred THEN
Error(HErrorInfo(hErrComplet))
END
IF HReadFirst(qry_file_CommonDB) THEN
Info(qry_file_CommonDB.userProfile)
END
ELSE
Error(HErrorInfo())
END


Error message on HReadFirst:


Error at line 30 of Global Procedure Run_Stored_Procedure_AIGCOmmonDB process.
HReadFirst function called.
The <qry_file_CommonDB> data source is not initialized.
- If it is a data file, the file was not found in the <C:\My Projects\BE_MINERVA\BE_MINERVA.wdd> analysis or it was not described by HDeclare/HDeclareExternal.
- If it is a query or a view, the execution may have failed.
To retrieve the corresponding error, check the result of HExecuteQuery/HExecuteSQLQuery/HCreateView.

----- Technical Information -----

Project : BE_MINERVA

WL call:
Process of 'Global Procedure Run_Stored_Procedure_AIGCOmmonDB' (Global_Procedures.Run_Stored_Procedure_AIGCOmmonDB), line 30, thread 0
'HReadFirst' function, syntax 3

What happened?
The <qry_file_CommonDB> data source is not initialized.
- If it is a data file, the file was not found in the <C:\My Projects\BE_MINERVA\BE_MINERVA.wdd> analysis or it was not described by HDeclare/HDeclareExternal.
- If it is a query or a view, the execution may have failed.
To retrieve the corresponding error, check the result of HExecuteQuery/HExecuteSQLQuery/HCreateView.

Error code: 70018
Level: fatal error (EL_FATAL)
WD55 error code: 18

Dump of the error of 'WD190HF.DLL' module (19.0.97.1).
Identifier of detailed information (.err): 70116
Debugging information:
IEWDHF=1.1
Module=<WDHF>
Version=<19.0.97.1>
Fonction (7,10)
Additional Information:
EIT_PATHWDD : <C:\My Projects\BE_MINERVA\BE_MINERVA.wdd>
EIT_LOGICALTABLENAME : <qry_file_CommonDB>
EIT_PILEWL :
Global Procedure Run_Stored_Procedure_AIGCOmmonDB (Global_Procedures.Run_Stored_Procedure_AIGCOmmonDB), line 30
Selecting the menu of _Menu.Test (WIN_Main._Menu.Test), line 1
EIT_DATEHEURE : 11/01/2018 10:12:43

Help

- Check that the file is described in the current analysis.
- For a dynamically described file, check that it has been properly
declared with HDeclare, HDeclareExternal or HDescribeFile.
- For a query created in the query editor, or a query written in
SQL language, check that it has been declared with HExecuteQuery
or HExecuteSQLQuery.




Stored procedure sp_getProfile_Minerva:


USE [AigCommonDb]
GO
/****** Object: StoredProcedure [dbo].[sp_getProfile_Minerva] Script Date: 01/11/2018 10:19:54 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[sp_getProfile_Minerva]
@userName nvarchar(50)

AS

DECLARE @countUserName int;
DECLARE @DEFAULT_PROFILE nvarchar(50);

SET @DEFAULT_PROFILE = 'RO'
SET @countUserName = (SELECT count(*) FROM User_Minerva WHERE [UserName] = @userName )
IF @countUserName = 0
BEGIN
INSERT INTO User_Minerva([UserName],[userProfile])
VALUES(@userName,@DEFAULT_PROFILE)
END


UPDATE User_Minerva
SET UserLastLogin = getdate()
WHERE [UserName] = @userName

SELECT [userProfile]
FROM User_Minerva
>WHERE [UserName] = @username






Note: The file User_Minerva is declared in the Analysis