Making a SQL Call from a Batch Handler
Is it possible to make a SQL call from a batch handler? I've got a line of code that looks like this.
Using conn As SqlConnection = Me.GetRequestContext.OpenAppDBConnection
This and the subsequent lines compile, but they do not work. When I run them I get a ‘stored procedure not found’. The stored procedure I am calling does work, I feel like the issue is there really is no OpenAppDBConnection I am grabbing here.
Thanks,
Ernie
Comments
-
I got around my initial problem. I am not sure why the syntax is a little different but in an import handler this works:
Using conn As SqlConnection = Me.GetRequestContext.OpenAppDBConnection
In a batch handler, I need to change GetRequestContext to RequestContext like this.
Using conn As SqlConnection = Me.RequestContext.OpenAppDBConnection()
With that tiny change out of the way I am able to call the database as expected. My next problem is permissions \\ security related on the new stored procedure I want to call. If I deploy the procedure through TSQL then the procedure is not even found in my code, although I know it exists. If I deploy it through loadspec it shows up just fine but complains I do not have rights to run the procedure.
I have reached out to someone responsible for permissions where I work. I am wondering does this require GRANT EXECUTE on the stored procedure at the database level or is Blackbaud somehow managing this. Things seem to work better when I operate using Blackbaud objects \\ and wrapers. I guess I will find out soon!
0 -
Continuing to make lots of progress with my project. I have my data call moved into calls, that can be called from multiple batch handlers or import handlers. It needs to be tidied up but it works.
I also have a bulk edit form. Essentially an edit form with two nested collection controls. I can call the class, and make the data call from this form, but it's causing major problems. I do not know where to make my call. I want to make my DB call and refresh one subfield in my collection on my edit form if an only if the user has changed another collection field.
The user changes CONSTITUENTGUID field, then ALT ID Field is auto refreshed on the collection record.
If I place this in the field changed event handler, the data refresh call is called with every keystroke (I think) and the page just spins and becomes non-responsive.
If I place this call in the validated event handler, it works, but only if validation fails.
Seems to me I want to place this call in a field or row loses or changes focus, but I don't see a handler like this.
Most of my goals have been accomplished, I just can figure this last bit out.
Here's the working code, that I am trying to add to the correct place.
For Each row In GROUPMEMBERS.Value
If row.Selected = True Then
Try
Dim myCONSTITUENTID As New Guid
myCONSTITUENTID = Guid.Parse(row.MEMBERID.Value.ToString)If String.IsNullOrEmpty(myCONSTITUENTID.ToString) = False Then
row.LOOKUPID.Enabled = True
Dim conn As SqlConnection = Me.GetRequestContext.OpenAppDBConnection() 'Me.RequestContext.OpenAppDBConnection()
Dim myUSRConstituent As New usr_myConstituent(myCONSTITUENTID, conn)row.LOOKUPID.Value = myUSRConstituent.LOOKUPID
row.LOOKUPID.Enabled = False
End If
Catch
End TryEnd If
Next0 -
Looking at some other posts about accessing collection fields I was able to move this around and getting running. Here's my revised code.
Private Sub _groupmembers_ActiveFieldChanged(sender As Object, e As ActiveFieldChangedEventArgs) Handles _groupmembers.ActiveFieldChanged
For Each row In GROUPMEMBERS.Value
If row.IsDirty = True Then
TryDim myCONSTITUENTID As New Guid
myCONSTITUENTID = Guid.Parse(row.MEMBERID.Value.ToString)If String.IsNullOrEmpty(myCONSTITUENTID.ToString) = False Then
Dim conn As SqlConnection = Me.GetRequestContext.OpenAppDBConnection()
Dim myUSRConstituent As New usr_myConstituent(myCONSTITUENTID, conn)row.LOOKUPID.Value = myUSRConstituent.LOOKUPID
row.ISDECEASED.Value = myUSRConstituent.ISDECEASED
End If
Catch
End Try
End IfNext
End Sub0 -
Set the following property at the top of your sproc spec.
GrantServiceRolePermission="true"
1 -
That got it done. Thank you!!!
0
Categories
- All Categories
- 6 Blackbaud Community Help
- 211 bbcon®
- 1.4K Blackbaud Altru®
- 396 Blackbaud Award Management™ and Blackbaud Stewardship Management™
- 1.1K Blackbaud CRM™ and Blackbaud Internet Solutions™
- 15 donorCentrics®
- 360 Blackbaud eTapestry®
- 2.5K Blackbaud Financial Edge NXT®
- 650 Blackbaud Grantmaking™
- 568 Blackbaud Education Management Solutions for Higher Education
- 3.2K Blackbaud Education Management Solutions for K-12 Schools
- 937 Blackbaud Luminate Online® and Blackbaud TeamRaiser®
- 84 JustGiving® from Blackbaud®
- 6.5K Blackbaud Raiser's Edge NXT®
- 3.7K SKY Developer
- 248 ResearchPoint™
- 119 Blackbaud Tuition Management™
- 165 Organizational Best Practices
- 239 The Tap (Just for Fun)
- 34 Blackbaud Community Challenges
- 31 PowerUp Challenges
- 3 (Open) PowerUp Challenge: Data Health
- 3 (Closed) Raiser's Edge NXT PowerUp Challenge: Product Update Briefing
- 3 (Closed) Raiser's Edge NXT PowerUp Challenge: Standard Reports+
- 3 (Closed) Raiser's Edge NXT PowerUp Challenge: Email Marketing
- 3 (Closed) Raiser's Edge NXT PowerUp Challenge: Gift Management
- 4 (Closed) Raiser's Edge NXT PowerUp Challenge: Event Management
- 3 (Closed) Raiser's Edge NXT PowerUp Challenge: Home Page
- 4 (Closed) Raiser's Edge NXT PowerUp Challenge: Standard Reports
- 4 (Closed) Raiser's Edge NXT PowerUp Challenge: Query
- 785 Community News
- 2.9K Jobs Board
- 53 Blackbaud SKY® Reporting Announcements
- 47 Blackbaud CRM Higher Ed Product Advisory Group (HE PAG)
- 19 Blackbaud CRM Product Advisory Group (BBCRM PAG)

