473,569 Members | 2,383 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 3958
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.Row SourceType is Value List.

Form_open Code is:

Private Sub Form_Open(Cance l As Integer)
Dim r As ADODB.Recordset
Dim TSQL As String
If SysCmd(acSysCmd GetObjectState, acForm, "frmAssignTeach ers") And
acObjStateOpen = acObjStateOpen Then
TSQL = "SELECT 0 AS fldTeacherID, NULL AS fldTeacherName" _
& vbNewLine & "UNION" & vbNewLine & _
"SELECT fldTeacherID, fldTeacherName FROM tblTeachers
WHERE fldSchoolID = " & Form_frmAssignT eachers.txtScho olID.Value & "
ORDER BY fldTeacherName"
With Me
.lstTeachers.Ro wSource = CurrentProject. Connection.Exec ute
(TSQL).GetStrin g(, , ",", ",")
.InsideHeight = Form_frmAssignT eachers.InsideH eight
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.Row SourceType is Value List.

Form_open Code is:

Private Sub Form_Open(Cance l As Integer)
Dim r As ADODB.Recordset
Dim TSQL As String
If SysCmd(acSysCmd GetObjectState, acForm, "frmAssignTeach ers") And
acObjStateOpen = acObjStateOpen Then
TSQL = "SELECT 0 AS fldTeacherID, NULL AS fldTeacherName" _
& vbNewLine & "UNION" & vbNewLine & _
"SELECT fldTeacherID, fldTeacherName FROM tblTeachers
WHERE fldSchoolID = " & Form_frmAssignT eachers.txtScho olID.Value & "
ORDER BY fldTeacherName"
With Me
.lstTeachers.Ro wSource = CurrentProject. Connection.Exec ute
(TSQL).GetStrin g(, , ",", ",")
.InsideHeight = Form_frmAssignT eachers.InsideH eight
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
13607
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 =...
4
8065
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 creates a string of custom SQL statement and returns this string back to the main stored procedure. This SQL statements work fine on there own....
2
5719
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 know why because I dont have anything refering to stored procedure 'S' I have ran my SQL String with sample values and it works fine. So I
3
10625
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 I try to use is with the stored procedure "xp_cmdshell". If I write in DOS prompt dtsrun /F c:\DTS1.dts the DTS1 will execute well
6
2794
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 then I can use these values to execute a SQL Server stored procedure to load them into the batch table from the input file (the stored procedure uses...
2
2739
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 procedure folder the procedure does not show up in the stored procedure list. When I entered 'exec Test' I get an error indicating that SQL Server 2005...
0
5793
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 but when the calling program enters the SP, it either hangs or gives me sqlcode -1131. We are on AIX 5.2 (I think) running DB2 UDB ver 7.2 and MF...
2
2438
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 monthly automaticaly if u'r suscribed in that site. i like this type of functionality. i use for this stored procedure : set ANSI_NULLS ON
0
3159
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 fine. Now we decided to move from mainframe IMS-DB2 to Windows 2003 server-DB2 UDB for LUW 9.5.
0
7926
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8132
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7678
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7982
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...
0
6286
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...
1
5514
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...
0
3656
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...
0
3644
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
944
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...

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.