all groups > dotnet windows forms databinding > march 2005 >
You're in the

dotnet windows forms databinding

group:

Databinding in VB.Net: Errors in debug mode but the application is working!


RE: Databinding in VB.Net: Errors in debug mode but the application is working! v-jetan NO[at]SPAM online.microsoft.com (
3/30/2005 6:25:05 AM
dotnet windows forms databinding:
Hi Sam,

Thanks for your posting!!

Based on my understanding, you have an application, which generates out of
range exception in debug mode, but in release mode, there will be exception
throw, and the application works well. If I misunderstand you, please feel
free to tell me.

First, what does "upgraded to 2003 MSDN" mean? Do you refer to VS.net 2003?
Also, can you show us which code statement does this exception throw out at
debug mode? Please clarify this for us. Thanks

Currently, from your description, it is still hard for us to reproduce out
the problem. So the understanding of this problem is also limited. I
suggest you provide some sample code snippet for us to reproduce out this.
Also, you may create a little sample project(which get rid of the
un-related code) and attach it in the reply, once the problem is reproduced
out, we can track to the root cause better.

I will wait for your further feedback. Thanks
=================================================
Thank you for your patience and cooperation. If you have any questions or
concerns, please feel free to post it in the group. I am standing by to be
of assistance.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
Databinding in VB.Net: Errors in debug mode but the application is working! Sam Downunder
3/30/2005 6:37:42 AM
Hi
I have an application that has in memory tables which are related. I
have recently upgraded to 2003 MSDN - which seems to have thrown an
error which I did not have before.

Here is the scenario...

First I build a couple of simple tables:

__________________________________________________

Dim new_relation As DataRelation
' make the tables
mLanguagesTable = MakeLanguagesTable()
mLanguageDS.Tables.Add(mLanguagesTable)

mTermDefinitionsTable = MakeDefinitionsTable("TermDefinitions")
mLanguageDS.Tables.Add(mTermDefinitionsTable)


' add relations
new_relation = New DataRelation("LanguageTerms",
mLanguagesTable.Columns(0), mTermDefinitionsTable.Columns(0))

mLanguageDS.Relations.Add(new_relation)

______________________________________________________


I then bind the tables to controls on the form....

The LanguagesTable to a list box..
______________________________________________________


Me.ListLanguages.DataSource =
Filemanager.Instance.OntologyManager.LanguagesTable

Me.ListLanguages.DisplayMember = "Language"
Me.ListLanguages.ValueMember = "id"
______________________________________________________

And then the relation to a Grid..


Me.DataGridDefinitions.DataSource =
Filemanager.Instance.OntologyManager.LanguagesTable

Me.DataGridDefinitions.DataMember = "LanguageTerms"
___________________________________________________________

This works, that is the application works fine - but if I set the
exception handling to stop at the error, I now see errors when doing
this binding (out of range exception) and when adding new rows to the
languages table.

The point is that the application works fine, and if I leave errors to
be handled in debug mode, I would not know there is a problem.

Just to make sure the make table routine is OK....
_______________________________________________________
Private Function MakeLanguagesTable() As DataTable
' Create a new DataTable titled 'Languages'
Dim LangTable As DataTable = New DataTable("Languages")
' Add two column objects to the table.
'First the language ID = two letter ISO code
Dim idColumn As DataColumn = New DataColumn
idColumn.DataType = System.Type.GetType("System.String")
idColumn.ColumnName = "id"
LangTable.Columns.Add(idColumn)
'Second the language text from windows/ISO list
Dim LanguageColumn As DataColumn = New DataColumn
LanguageColumn.DataType = System.Type.GetType("System.String")
LanguageColumn.ColumnName = "Language"
LangTable.Columns.Add(LanguageColumn)
' Create an array for DataColumn objects.
Dim keys(0) As DataColumn
keys(0) = idColumn
LangTable.PrimaryKey = keys
' Return the new DataTable.
Return LangTable
End Function
_________________________________________________________

AddThis Social Bookmark Button