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

Stored procedure to fill listbox, using 'exec'

Hey,

Coming back to a piece of work I did a while back, which used a stored
procedure to populate a list box. The SP takes a single parameter, and
I think this is the reasoning for using 'exec' in the row source (I
assume you need this for parameters?)

The problem is this only works when I access the form.. If I do it from
someone else's computer they get a blank listbox. They have appropriate
permissions for the stored procedure, so is the 'exec' getting in the way?

Can I use a parameterised sp in a row source for a listbox without using
exec? or is there a way of sorting it that the user can use the stored
procedure? (there's no error messages to say there's no access)

The stored procedure was created using my login, not dbo (if that makes
a difference)

Thanks for any help you can give!
Chris
Nov 13 '05 #1
2 3937
Not Me <No***********@here.com> wrote in
news:ci**********@ucsnew1.ncl.ac.uk:
Hey,

Coming back to a piece of work I did a while back, which used a stored
procedure to populate a list box. The SP takes a single parameter,
and I think this is the reasoning for using 'exec' in the row source
(I assume you need this for parameters?)

The problem is this only works when I access the form.. If I do it
from someone else's computer they get a blank listbox. They have
appropriate permissions for the stored procedure, so is the 'exec'
getting in the way?

Can I use a parameterised sp in a row source for a listbox without
using exec? or is there a way of sorting it that the user can use the
stored procedure? (there's no error messages to say there's no access)

The stored procedure was created using my login, not dbo (if that
makes a difference)

Thanks for any help you can give!
Chris


Recently I have resorted to using a string as follows:

***************************************
lstTeachers.RowSourceType is Value List.

Form_open Code is:

Private Sub Form_Open(Cancel As Integer)
Dim r As ADODB.Recordset
Dim TSQL As String
If SysCmd(acSysCmdGetObjectState, acForm, "frmAssignTeachers") And
acObjStateOpen = acObjStateOpen Then
TSQL = "SELECT 0 AS fldTeacherID, NULL AS fldTeacherName" _
& vbNewLine & "UNION" & vbNewLine & _
"SELECT fldTeacherID, fldTeacherName FROM tblTeachers
WHERE fldSchoolID = " & Form_frmAssignTeachers.txtSchoolID.Value & "
ORDER BY fldTeacherName"
With Me
.lstTeachers.RowSource = CurrentProject.Connection.Execute
(TSQL).GetString(, , ",", ",")
.InsideHeight = Form_frmAssignTeachers.InsideHeight
End With
PlaceForm Me
End If
End Sub
*******

In the code there are procedures extraneous to the question at hand, of
course. As ever, line breaks introduced by news clients can make code
unusable without editing.

There does not seem to be any noticeable time penalty for this way of
doing things. As far as I know, it is the only way to use the equivalent
of parameterized stored procedures with Application Role MS-SQL
permissions and ADPs.


Nov 13 '05 #2
Lyle Fairfield wrote:
Not Me <No***********@here.com> wrote in
news:ci**********@ucsnew1.ncl.ac.uk:
Hey, <snip>Can I use a parameterised sp in a row source for a listbox without
using exec? or is there a way of sorting it that the user can use the
stored procedure? (there's no error messages to say there's no access)
Recently I have resorted to using a string as follows:

***************************************
lstTeachers.RowSourceType is Value List.

Form_open Code is:

Private Sub Form_Open(Cancel As Integer)
Dim r As ADODB.Recordset
Dim TSQL As String
If SysCmd(acSysCmdGetObjectState, acForm, "frmAssignTeachers") And
acObjStateOpen = acObjStateOpen Then
TSQL = "SELECT 0 AS fldTeacherID, NULL AS fldTeacherName" _
& vbNewLine & "UNION" & vbNewLine & _
"SELECT fldTeacherID, fldTeacherName FROM tblTeachers
WHERE fldSchoolID = " & Form_frmAssignTeachers.txtSchoolID.Value & "
ORDER BY fldTeacherName"
With Me
.lstTeachers.RowSource = CurrentProject.Connection.Execute
(TSQL).GetString(, , ",", ",")
.InsideHeight = Form_frmAssignTeachers.InsideHeight
End With
PlaceForm Me
End If
End Sub
*******
There does not seem to be any noticeable time penalty for this way of
doing things. As far as I know, it is the only way to use the equivalent
of parameterized stored procedures with Application Role MS-SQL
permissions and ADPs.


Thanks for that, I will look into it as it should help my understanding
of this better, though in the meantime I seem to have fixed the problem
by changing the ownership of the procedures to 'dbo'.

Cheers,
Chris
Nov 13 '05 #3

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 *...
4
by: MD | last post by:
I am trying to create a dynamic SQL statement to create a view. I have a stored procedure, which based on the parameters passed calls different stored procedures. Each of this sub stored procedure...
2
by: Caro | last post by:
I have a stored procedure spGetAccessLogDynamic and when I try to call it I get the following error: Server: Msg 2812, Level 16, State 62, Line 1 Could not find stored procedure 'S'. I dont...
3
by: Cesco | last post by:
Hallo to everybody. I have a DTS in SQL Server 2000 and I need to execute it from stored procedure. I know that there are various method fot does this but they doesn't work. The first method that...
6
by: fumanchu | last post by:
I've got to let end users (really just one person) load billing batch files into a third party app table. They need to specify the billing cycle name, the batch name, and the input file name and...
2
by: Crazy Cat | last post by:
Hi, I wrote the following in the SQL Server 2005 Express Management Studio Query Analyzer and hit execute. Even though Query Analyzer indicated success when I hit refresh on the stored...
0
by: pompeyoc | last post by:
I am trying to learn how to use stored procedures written in COBOL so I wrote 2 small programs to test it out: the stored procedure and the the calling program. I have no problems compiling them...
2
by: shahnawaz shaikh | last post by:
hi friends i want to send email thoruth stored procedure or i want to give functionality like alert which is send email automaticaly from database. just like a news or any ad email weekly or...
0
by: SOI_0152 | last post by:
Hi all! Happy New Year 2008. Il hope it will bring you love and happyness I'm new on this forum. I wrote a stored procedure on mainframe using DB2 7.1.1 and IBM language c. Everything works...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.