I cannot give the meaning of this exception

Socarsky

Well-known member
Joined
Mar 3, 2014
Messages
59
Programming Experience
Beginner
I cannot give the meaning of this issue. If I dont use this method then the conn. works well.
Datarows.jpg
 

jmcilhinney

C# Forum Moderator
Staff member
Joined
Apr 23, 2011
Messages
3,144
Location
Sydney, Australia
Programming Experience
10+
Firstly, please don't post screenshots of code as a first option. If you want to post code then post code, i.e.

[xcode=c#]your code here[/xcode]

That way we can easily copy the code and do various things with it, e.g. run it or quote part of it.

Secondly, you should look at the actual exception being thrown and not just provide a generic error message regardless. You don't necessarily have to tell the user but you at least should know exactly what the low-level issue was.

As for the issue itself, take a look at your code, which I have had to retype by hand because you posted a screenshot instead of actual code:
C#:
if ([B][COLOR="#FF0000"]dt[/COLOR][/B] != null && [B][COLOR="#FF0000"]dt[/COLOR][/B].Rows.Count > 0)
{
    FindInTable([B][COLOR="#008000"]dtClone[/COLOR][/B], "T1");
}
What's the point of testing for the existence of rows in `dt` when it's `dtClone` that you're passing to the method?
 

Socarsky

Well-known member
Joined
Mar 3, 2014
Messages
59
Programming Experience
Beginner
Firstly, please don't post screenshots of code as a first option. If you want to post code then post code, i.e.

[xcode=c#]your code here[/xcode]

That way we can easily copy the code and do various things with it, e.g. run it or quote part of it.
Sorry for my wrong choosing to show things with a screenshot. Yes You are right.

Secondly, you should look at the actual exception being thrown and not just provide a generic error message regardless. You don't necessarily have to tell the user but you at least should know exactly what the low-level issue was.

As for the issue itself, take a look at your code, which I have had to retype by hand because you posted a screenshot instead of actual code:
C#:
if ([B][COLOR=#FF0000]dt[/COLOR][/B] != null && [B][COLOR=#FF0000]dt[/COLOR][/B].Rows.Count > 0)
{
    FindInTable([B][COLOR=#008000]dtClone[/COLOR][/B], "T1");
}
What's the point of testing for the existence of rows in `dt` when it's `dtClone` that you're passing to the method?
I need to know whether the Datatable filled with data or not then if it is possible I try to find an exactly string type letters.
By the way I found the program where comes from. So, the cloned Datatable does not have a primarykey. That's why the method went wrong.
 

Socarsky

Well-known member
Joined
Mar 3, 2014
Messages
59
Programming Experience
Beginner
I'm sorry I have to show these screenshots anyway this time to make my condition clarify.

dtClone copied by origin DataTable which called dt. As you can see all columns and rows already copied into dtClone.
dtClone and dt have their primarykey as first columns[0] But there was an error related PrimaryKey in dtClone when I want to use Find method in DataTable.
datatable-1.jpg
datatable-1a.jpg

This is another error and it is right because first column has some the same code in the first column of dtClone.
datatable-2.jpg

I only want to concatenate MultiColumnComboBox's two columns' strings as one variable then assign it combobox.text that's all but I thought to copy origin DataTable's data to another one and find selectedText's value in first column of dbClone then after finding concatenate them. But now the case taken an interesting state.
 

Socarsky

Well-known member
Joined
Mar 3, 2014
Messages
59
Programming Experience
Beginner
Thanks to someone's ideas that caused me to see a clever way to get a right attempt with small effort.
I removed alternative DataTable which I thought to get a positive result with my desire.
I only add a concatenate column to my query string and changed a few code then voila.
concatenated2.jpg
 
Top Bottom