Click here to Skip to main content
15,894,646 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: Form Design Pin
Tom John30-Nov-04 5:55
Tom John30-Nov-04 5:55 
GeneralRe: Form Design Pin
The Man from U.N.C.L.E.2-Dec-04 1:29
The Man from U.N.C.L.E.2-Dec-04 1:29 
QuestionHow to handle a propertyvaluechanged event ( or any event) correctly? Pin
David M J29-Nov-04 9:28
David M J29-Nov-04 9:28 
AnswerRe: How to handle a propertyvaluechanged event ( or any event) correctly? Pin
Tom John30-Nov-04 5:50
Tom John30-Nov-04 5:50 
GeneralEmpty Dataset via Stored Procedure Pin
NorthernExposure29-Nov-04 6:51
NorthernExposure29-Nov-04 6:51 
GeneralRe: Empty Dataset via Stored Procedure Pin
NorthernExposure30-Nov-04 21:13
NorthernExposure30-Nov-04 21:13 
GeneralRe: Empty Dataset via Stored Procedure Pin
Colin Angus Mackay1-Dec-04 0:41
Colin Angus Mackay1-Dec-04 0:41 
GeneralRe: Empty Dataset via Stored Procedure Pin
NorthernExposure1-Dec-04 6:36
NorthernExposure1-Dec-04 6:36 
First, let me thank you Colin & Dave for replying with what you did. Even that little bit helped get me pointed in the right direction.

I did not, and do not, want to insult the "experts" but it is frustrating to post what I thought was a legitimate problem and get absolutely nothing back. Like you, I am very busy and do not want to waste anyone's time, especially with simple issues that anyone can find the answers to in the plethora of on-line documentation that is available. I am a self-taught VB.Net programmer (actually in the process of self-teaching) and everyone knows that in that situation you have a fool for a teacher.

Your comment re the Stack helped me isolate where the real problem is and I have developed a work-around but not a solution. Here's the scoop:

I am trying to develop an n-tier application with a Windows GUI, business objects to process validation and functionality etc and a data layer to do the actual data retrievals using SQL 2000, data adapters and typed datasets. In this situation where the problem is occuring, I have 1 combobox (ComboboxA)loaded with values from a main table (dsMain) and a 2nd combobox (ComboboxB)loaded with related records from a second table (dsSub). When I select a different item from ComboboxA, I paint an area on the screen with pertinent data from the dsMain record. I then use the key from dsMain to call a business object (boSub) to retrieve the associated child records into dsSub by passing the key value to boSub. boSub issues a call to the data tier (dtSub) to use a data adapter to fill the dsSub with the results of a stored procedure that retrieves all records that match the key value passed to the procedure with a parameter that contains the key value. When there is a match on the key value, dsSub is returned up the ladder to the WIndows GUI, ComboboxB is filled with the results and a separate screen area is painted with data elements from the selected entry in ComboboxB (which, when there is data is initially defaulted to item # 0).

The error was/is occuring when there is no match on the key that is passed (ie no related child records in dsSub) and the program was tring to paint the screen area using data from a non-existent record in dsSub (hence the reference to an index = -1)

The problem is actually happening (I believe) because the program is not recognizing that an empty dataset has been returned even though I have code that is supposed to be trapping for this event. What I have done to check for an empty dataset condition is as follows:

In the business object (boSub) I have created a boolean property called EmptyDataset that is set to false when boSub is instantiated. In boSub, I test for an empty dataset and if that occurs, I set EmptyDataset = True. In the Windows GUI, when dsSub is returned, if EmptyDataset = False, I paint the screen. The problem is that EmptyDataset is not being set to True. This is the actual trapping code that I am using in boSub:

Public Class LenderOptionsBO
Inherits MortgageOptionsDC

Private mbolDSEmpty As Boolean = False
Property EmptyDataset() As Boolean
Get
Return mbolDSEmpty
End Get
Set(ByVal Value As Boolean)
mbolDSEmpty = Value
End Set
End Property

Public Sub New()
EmptyDataset = False

End Sub

Public Shadows Function GetByPKLenOpt( _
ByRef Lmo_id As String) As OptionsByLender
Dim dsOptions As OptionsByLender = New OptionsByLender()

Try
dsOptions = MyBase.GetByPKLenOpt(Lmo_id)

Catch ex As Exception When dsOptions.OptionsByLender.Rows.Count = 0
EmptyDataset = True
Catch exp As Exception
Throw exp

End Try

Return dsOptions
End Function

The code: Mybase.GetByPKLenOpt(Lmo_id) is as follows:

Public Overridable Overloads Function GetByPKLenOpt( _
ByRef ID As String) As OptionsByLender
'
' Get all mortgage options for a lender
'
Dim connection As SqlClient.SqlConnection = New SqlClient.SqlConnection("data source=AGSERVER001;initial catalog=MortgageMulcher;integrated security=SSPI;persist security info=True")

Dim dsOptions As OptionsByLender = New OptionsByLender()
Dim command As SqlClient.SqlCommand = New SqlClient.SqlCommand()
Dim daMrtgOptions As SqlClient.SqlDataAdapter = New SqlClient.SqlDataAdapter()

Dim LenderID As SqlClient.SqlParameter = New SqlClient.SqlParameter()

command.Connection = connection
command.CommandText = "stpOptionsByLender"

command.CommandType = CommandType.StoredProcedure
LenderID.ParameterName = "@Lender_id"
LenderID.DbType = DbType.String
LenderID.Size = 10
LenderID.Value = ID

command.Parameters.Add(LenderID)

daMrtgOptions.SelectCommand = command

daMrtgOptions.Fill(dsOptions, "OptionsByLender")
Return dsOptions

End Function

The code in the Windows GUI where I am checking for an empty dataset is:

Dim i As Integer, bolo As LenderOptionsBO = New LenderOptionsBO(), strid As String
i = cboLenders.SelectedIndex
strid = dsLenders.tblLender(i).Len_id
dsLenOptions = bolo.GetByPKLenOpt(strid)
If bolo.EmptyDataset = True Then
MessageBox.Show("This is an empty dataset")
End If

When there is an actual empty dataset, I am not getting the Messagebox displayed, it is falling through the code and causing the crash.

For the life of me, I cannot see why EmptyDataset = True is not being triggered.

I'm sorry that I have been so verbose. Hopefully one of you can see what stupid mistake I have made.

TIA

Bruce

Happy Hunting
GeneralRe: Empty Dataset via Stored Procedure Pin
Dave Kreskowiak1-Dec-04 0:47
mveDave Kreskowiak1-Dec-04 0:47 
GeneralTab pages Pin
Paps229-Nov-04 6:49
Paps229-Nov-04 6:49 
GeneralRe: Tab pages Pin
Tom John30-Nov-04 6:02
Tom John30-Nov-04 6:02 
GeneralDelete folder with vb.net Pin
sybux200029-Nov-04 4:47
sybux200029-Nov-04 4:47 
GeneralRe: Delete folder with vb.net Pin
Tom John30-Nov-04 6:28
Tom John30-Nov-04 6:28 
GeneralRe: Delete folder with vb.net Pin
sybux200030-Nov-04 7:58
sybux200030-Nov-04 7:58 
QuestionCan any Body Help ME with my project Pin
geekru229-Nov-04 3:32
geekru229-Nov-04 3:32 
AnswerRe: Can any Body Help ME with my project Pin
Dave Kreskowiak1-Dec-04 3:33
mveDave Kreskowiak1-Dec-04 3:33 
AnswerRe: Can any Body Help ME with my project Pin
Dave Kreskowiak2-Dec-04 1:04
mveDave Kreskowiak2-Dec-04 1:04 
GeneralRe: Can any Body Help ME with my project Pin
geekru23-Dec-04 7:04
geekru23-Dec-04 7:04 
GeneralRe: Can any Body Help ME with my project Pin
Dave Kreskowiak3-Dec-04 12:32
mveDave Kreskowiak3-Dec-04 12:32 
GeneralIs this Possible - Getting a Application Name Pin
cwayman29-Nov-04 2:45
cwayman29-Nov-04 2:45 
GeneralRe: Is this Possible - Getting a Application Name Pin
Tom John30-Nov-04 6:05
Tom John30-Nov-04 6:05 
GeneralRe: Is this Possible - Getting a Application Name Pin
cwayman30-Nov-04 7:18
cwayman30-Nov-04 7:18 
QuestionHow to intercept Remote system calls? Pin
Zenly29-Nov-04 2:21
Zenly29-Nov-04 2:21 
QuestionHow to Read/Write Disk blocks? Pin
Zenly29-Nov-04 2:17
Zenly29-Nov-04 2:17 
AnswerRe: How to Read/Write Disk blocks? Pin
Dave Kreskowiak29-Nov-04 3:28
mveDave Kreskowiak29-Nov-04 3:28 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.