.NETGURU
DataTable.Select method bug (?) with .net framework 1.1 SP1
Messages   Related Types
This message was discovered on microsoft.public.dotnet.framework.adonet.
Responses highlighted in red are from those people who are likely to be able to contribute good, authoratitive information to this discussion. They include Microsoft employees, MVP's and others who IMHO contribute well to these kinds of discussions.
Post a new message to this list...

Mayo (VIP)
I was using the Select method without any problem, but when I installed SP1
for the Framework 1.1 I got into troubles: the overloaded method:

Overloads Public Function Select(String) As DataRow()

doesn't seem to work correctly. It seems to forget some of the final where
conditions, not all...
If I compile the code or run on a PC without SP1 it works correctly.

the following is the code where dtDL is my DataTable:

sWhere = "MCLV = '" & sMcLv & "'"
sWhere = sWhere & " AND CodPrd = '" & sCdPrd & "'"
sWhere = sWhere & " AND Anno = " & oOutPrd.currYear
sWhere = sWhere & " AND SmRi >= " & oOPrd.sDa & " AND SmRi <= " & oOPrd.sA
draResult = dtDL.Select(sWhere)

In this case it seems to miss the following part:
" AND SmRi >= " & oOPrd.sDa & " AND SmRi <= " & oOPrd.sA

but if I put this part at the beginning of the filter expression it is used...

please help!
Reply to this message...
 
    
Jon Skeet [C# MVP] (VIP)
Mayo <Click here to reveal e-mail address> wrote:
[Original message clipped]

What happens if you print out sWhere before using it for the selection?
Is it all there?

Is it possible that one of your values contains an apostrophe? This is
one of the (many) benefits of using SQL parameters rather than putting
everything in the SQL statement...

--
Jon Skeet - <Click here to reveal e-mail address>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Reply to this message...
 
    
Mayo (VIP)
Yes I did it, here is the result:
sWhere = "MCLV = '32X32XD' AND CodPrd = '15934' AND Anno = 2004 AND SmRi >=
37 AND SmRi <= 37"
but I remind you that it works fine in any pc without SP1 for .net
framework... I tried also to build a DataView with the same filter
expression, but the problem is the same...

what about parameters? How can I use them?
Thanks for your interest...

"Jon Skeet [C# MVP]" wrote:

[Original message clipped]

Reply to this message...
 
    
Jon Skeet [C# MVP] (VIP)
Mayo <Click here to reveal e-mail address> wrote:
[Original message clipped]

Ah - sorry, I hadn't noticed it was DataTable.Select - you can't use
parameters there, unfortunately :(

Have you tried quoting even the numeric values? I don't know whether
that'll help, but it couldn't hurt to try.

It's always struck me that things like DataTable.Select and
DataView.Filter could do with letting you plug your own code in... some
things are really easily expressed in code, but a pain to specify in
the limited expression language available :(

You say that if you have it at the start of the expression everything
works - is there any reason you can't just do that then?

--
Jon Skeet - <Click here to reveal e-mail address>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Reply to this message...
 
    
Mayo (VIP)
Yes I have tried quoting even the numeric values, but the result is the same.
I've made some tests building the DataSet and the DataTable starting from an
XML Schema (you know: SQLConnection->SQLDataAdapter->Generate DataSet) and
doing the same .Select on the DataTable works correctly. In my real case I
build the DataTable by myself with a code like this:
foreach(string colHeadName in ColNamesSet)
{
    sCurName = colHeadName;
    DataColumn newCol = dtValueSet.Columns.Add(sCurName, ColTypeSet[iColLoop]);
    alCheckNames.Add(sCurName);
    iColLoop++;
}

for(int rowIndex = 0;rowIndex<ALRows.Count;rowIndex++)
{
    DataRow newRow = dtValueSet.NewRow();
    newRow.ItemArray = RowToArray(rowIndex);
    dtValueSet.Rows.Add(newRow);
}

Why does this became a problem with SP1?

Thanks again Jon...

"Jon Skeet [C# MVP]" wrote:

[Original message clipped]

Reply to this message...
 
    
Mayo (VIP)
I can say more: I tried to write in a file the xsd schema of my dinamically
created datatable and, guess what... It is identical (apart from
minoccurs='0') to the xsd schema created by the VS2003 designer that works
fine!

So I tried to Load the xsd schema in a new dataset, but the problem remains...

the solution with SP1 seems to be: if you want to use DataTable do it only
statically?

"Mayo" wrote:

[Original message clipped]

Reply to this message...
 
 
System.Data.DataColumn
System.Data.DataRow
System.Data.DataSet
System.Data.DataTable
System.Data.DataView




ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
Ad


Need Dot Net Interview Questions?
Ask ExamGuru, Inc. for advice and help on Passing .Net Interviews
.Net Projects
Best-of-breed application framework for .NET projects, developed by ExamGuru, Inc. and ExamGuru IT
Free .net Help
Commission ExamGuru, Inc. and his team for your next bespoke software project
FogBUGZ
The only bug tracking system carefully crafted with one goal in mind: helping teams create great software.
Awesome Tools
If you don't know about these, you're missing out... IT Certification Questions
IT Interview Questions
Free Oracle 10g Training
MCSE Boortcamp
Cisco Study Guides
Cheap Study Guides
Exact Questions
Dot Net Interview Questions
Oracle OCP
Cheap Travel
Designer Perfumes - Wholesale Prices
Free Programming Tutorials
 
ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
 Copyright © ExamGuru, Inc. 2001-2006
Contact Us - Terms of Use - Privacy Policy - www.dot-net-guru.com - www.examguru.net - www.oraclesource.net - www.itinterviews.net - www.examguru.net/ITCertification