Unhandle SQL Exception Thrown


Author
Message
Ben Kim
Ben Kim
StrataFrame User (207 reputation)StrataFrame User (207 reputation)StrataFrame User (207 reputation)StrataFrame User (207 reputation)StrataFrame User (207 reputation)StrataFrame User (207 reputation)StrataFrame User (207 reputation)StrataFrame User (207 reputation)StrataFrame User (207 reputation)
Group: Forum Members
Posts: 99, Visits: 253
Hopefully this is my last question of the day!  Sorry to be so active here today!

This is not something I would do in production but... In my POC application, I changed the BrowseDialog1.MaximumReturnedRecords to 10,000.  When I do a search with no criteria (bring back the first 10,000 entries), I receive the attached exception regardless which record I select for edit, upon return to the entry form.  If I change the MaximumReturnedRecords back to 1,000 (the default), all is well.

Can someone shed some light on this error?

Thanks!

Ben

Attachments
SF_sqlexception.JPG (146 views, 93.00 KB)
SF_PriorToException.JPG (157 views, 77.00 KB)
Replies
Trent Taylor
Trent Taylor
StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 7K
You would have to click the View detail and give me all of the exceptions to give you an exact answer.  But your problem is directly related to size.  More than likely a MemoryException.  You should really never bring back that many records for a table with more than a couple of fields.  I am not sure of your background, but you have to work in a disconnected environment and should only bring back small quantities of records. 

10,000 is too many and I would recommend reworking your logic so that you work in smaller data sets.  If you set the MaximumRecords to 1500 I would doubt that the error would occur.

Ben Kim
Ben Kim
StrataFrame User (207 reputation)StrataFrame User (207 reputation)StrataFrame User (207 reputation)StrataFrame User (207 reputation)StrataFrame User (207 reputation)StrataFrame User (207 reputation)StrataFrame User (207 reputation)StrataFrame User (207 reputation)StrataFrame User (207 reputation)
Group: Forum Members
Posts: 99, Visits: 253
As I stated in the post "not that I would do this in production"... Attached is the details expanded.  I want to make sure to plug any holes in the framework (perhaps a more graceful message than this exception) to shield our developers (AND ultimately our end-users) from such exceptions.

Ben

Attachments
SF_ExceptionDetail.JPG (151 views, 73.00 KB)
Trent Taylor
Trent Taylor
StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 7K
I am not sure what the error is, but you can turn on data debugging to look at the SELECT statement and even run it manually through SQL Server Management Studio to see if the same error occurs.  This is a SQLexpcetion so something happened on the SQL Server....which could be memory as well.

To turn on data debugging do the following:

In the AppMain.vb (or program.cs) file, go to the SetDataSourcesMethod.  After the SetConnections method, add the following code:

MicroFour.StrataFrame.Data.DataBasics.DataSources(0).SetDebugOn("C:\mydebug.html",True)

Run your program and after the app closes the HTML doc will pop up (if it doesn't you can manually open it).

Ben Kim
Ben Kim
StrataFrame User (207 reputation)StrataFrame User (207 reputation)StrataFrame User (207 reputation)StrataFrame User (207 reputation)StrataFrame User (207 reputation)StrataFrame User (207 reputation)StrataFrame User (207 reputation)StrataFrame User (207 reputation)StrataFrame User (207 reputation)
Group: Forum Members
Posts: 99, Visits: 253
Well you may not like what I have to report.  The first SELECT TOP 10000... works just fine.  I assume when I click OK on the BrowseDialog the second SELECT statement is created and send to the backend.  The string is huge (> 4meg) setting up params such as NameNo=Parm1 OR ... NameNo=Parm9999 OR NameNo=ParmXXXX.

I attached the debug HTML document for your review.  Is this how the select statement should be formed???  I would have sent the same SELECT TOP 10000... again personally Smile (again not that I would do that in production! LOL)

Ben

Attachments
mydebug.zip (132 views, 156.00 KB)
Ben Kim
Ben Kim
StrataFrame User (207 reputation)StrataFrame User (207 reputation)StrataFrame User (207 reputation)StrataFrame User (207 reputation)StrataFrame User (207 reputation)StrataFrame User (207 reputation)StrataFrame User (207 reputation)StrataFrame User (207 reputation)StrataFrame User (207 reputation)
Group: Forum Members
Posts: 99, Visits: 253
Take a close look at the debug log.  It is the child table that is causing the problem!

NameLoca --->  AddrHist

Shouldn't it just be selecting the child records for the "current" NameLoca record and not ALL based on the filtered return from the BrowseDialog form???

Ben

Trent Taylor
Trent Taylor
StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 7K
Well, I am confident that it is not within the framework but more than likely the stop-gap between the data access layer and the ADO.NET data table.  Deductive reasoning on this one will point to a size or memory issue.  If you debug the 1000 statment and the 10000 statement, you will see one character different (a zero).  We are just filling a data table with an adapter....and over time, when we have stopped and debugged this type of error thinking it may be something in the framework, we have found...everytime thus far....it is a memory issue because too much data is coming back.

Hope this helps.

Trent Taylor
Trent Taylor
StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 7K
The problem you are running into isn't the 10000 return results, if you look at the second SELECT statement, there is a query with more than 4096 parameters....this is a limitation of SQL Server.  This table is selecting from AddrHist, I am not sure where this query is being generated, but it is definitely going to produce an SqlException because you have too many parameters being passed.
Trent Taylor
Trent Taylor
StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 7K
Do you have code to load up the child records automatically (i.e. Navigated event, BusinessLayerLinkManager, etc.)?  In other words when you click the OK button?  If so, this is the problem because the 4096 parameter limit is being hit.  THere is nothing we can do about this....it is just how SQL Server is.

You will have to reduce your recordset size.

Ben Kim
Ben Kim
StrataFrame User (207 reputation)StrataFrame User (207 reputation)StrataFrame User (207 reputation)StrataFrame User (207 reputation)StrataFrame User (207 reputation)StrataFrame User (207 reputation)StrataFrame User (207 reputation)StrataFrame User (207 reputation)StrataFrame User (207 reputation)
Group: Forum Members
Posts: 99, Visits: 253
This is the only code I have which could be causing the issue I assume:

Private Sub NameLocaBO1_Navigated(ByVal e As MicroFour.StrataFrame.Business.NavigatedEventArgs) Handles NameLocaBO1.Navigated
 If NameLocaBO1.Count > 0 Then
   
Me.AddrHistBO1.FillByParent()
   
Me.ugAddressHistory.Refresh()
 End If
End Sub

So  If I do FillByParentPrimaryKey how do I do it with a relationship that is multi-component?

NameLoca
     PersBuss (1st component of primary key)
     NameNo (2nd component of primary key)

AddrHist
     PersBuss (1st component of primary key)
     NameNo (2nd component of primary key)
     HistDT (3rd component of primary key)

AddrHist.PersBuss = NameLoca.PersBuss
AddrHist.NameNo = NameLoca.NameNo

Ben


Trent Taylor
Trent Taylor
StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 7K
This is your problem....and there is no way around it due to the SQL Server limitations.  The FillByParent is going to create a lot of parameters due to the nature of the relationship.  In this example, FillByparentPrimaryKey is going to retrieve the exact same record set but will only have 1 parameter which will be much faster anyway since there is not nearly as much TDS (SQL Server Tabular Data Stream) data that will go over the network.  Whether you are using SF or anything else, this is still not a good idea and you are going to have the same problems.

However, at least using SF you can call the FillByParentPrimarykey and your current problem should go away.

Trent Taylor
Trent Taylor
StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 7K
After looking at your previous post again, the relationship may not support the FillByParentPrimary key, but in any case, you are going to have to reduce the record size of the parent table....otherwise you are going to continue to have this problem....and there isn;t anything we can do about it....it isn't our limitation, it is SQL Servers....which honestly makes sense.  The record set is too large.
Ben Kim
Ben Kim
StrataFrame User (207 reputation)StrataFrame User (207 reputation)StrataFrame User (207 reputation)StrataFrame User (207 reputation)StrataFrame User (207 reputation)StrataFrame User (207 reputation)StrataFrame User (207 reputation)StrataFrame User (207 reputation)StrataFrame User (207 reputation)
Group: Forum Members
Posts: 99, Visits: 253
Forget it.  I think I found my answer in one of the overloaded methods of FillByParentKey!

On the addresshistory business object the ParentRelationship is:

NameLocaBO, (PersBuss,NameNo) <--> (PersBuss,NameNo)

If I change my method call to:

Me.AddrHistBO1.FillByParentPrimaryKey(NameLocaBO1.PersBuss, NameLocaBO1.NameNo)

All is well!  Thank you for such stellar support!

Ben


Trent Taylor
Trent Taylor
StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 7K
Good to hear you're going Smile
Trent Taylor
Trent Taylor
StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 7K
Wen you mentioned "multi-key" I presume you were referring to Compound Primary Keys....in this case, SF auto-detects and has full support for compound primary keys, which you discovered.
GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Threaded View
Threaded View
Ben Kim - 19 Years Ago
Trent L. Taylor - 19 Years Ago
Ben Kim - 19 Years Ago
Trent L. Taylor - 19 Years Ago
Ben Kim - 19 Years Ago
                         Take a close look at the debug log. It is the child table that is...
Ben Kim - 19 Years Ago
                         Well, I am confident that it is not within the framework but more than...
Trent L. Taylor - 19 Years Ago
                             The problem you are running into isn't the 10000 return results, if...
Trent L. Taylor - 19 Years Ago
                                 Do you have code to load up the child records automatically (i.e....
Trent L. Taylor - 19 Years Ago
                                     This is the only code I have which could be causing the issue I...
Ben Kim - 19 Years Ago
                                         This is your problem....and there is no way around it due to the SQL...
Trent L. Taylor - 19 Years Ago
                                             After looking at your previous post again, the relationship may not...
Trent L. Taylor - 19 Years Ago
                                         Forget it. I think I found my answer in one of the overloaded methods...
Ben Kim - 19 Years Ago
                                             Good to hear you're going :)
Trent L. Taylor - 19 Years Ago
                                                 Wen you mentioned "multi-key" I presume you were referring to Compound...
Trent L. Taylor - 19 Years Ago

Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search