Retrieve data using datarow with parameter

  • Thread starter Thread starter Coderz
  • Start date Start date
C

Coderz

I have this line of code working from my previous source code updated
to version 2008 of VB.NET

Dim drRegularLoadID() As DataRow =
dsStudentCourse.Tables("RegularLoad").Select("ProgramID = " &
intProgramID & " And MajorID = " & intMajorID & " And Semester = '" &
SemValue & "' And Year = '" & YearValue & "'")

If drRegularLoadID.Length = 0 Then
MessageBox.Show("No matching record(s)
found.")
Exit Sub
End If

This is working fine. However I have created a new project and is
using a latest connection using tableadapter instead of dataadapter. I
do not think this has something to do with the code above since the
only code I've change is only the dataset which is dsStudentCourse.

In my new project I just simply change the dsStudentCourse to
EnrollSystemDataSet.

Here it is:

Dim drRegularLoadID() As DataRow =
EnrollSystemDataSet.Tables("RegularLoad").Select("ProgramID = " &
intProgramID & " And MajorID = " & intMajorID & " And Semester = '" &
SemValue & "' And Year = '" & YearValue & "'")

But it does not return a record.

I am thinking about the dataset that causes the problem. But I do not
think so.

Any ideas?
 
Do a

Console.Writeline( EnrollSystemDataSet.GetXml() )

And look at the xml to see if the match is there or not.

You can also

EnrollSystemDataSet.WriteXml ( "C:\DSXML_" + Guid.NewGuid.ToString("N") +
".xml" )

and open the file in notepad.

That'll let you know what data is in the DataSet faster than anything else.
 
Are you sure that the dataset contains records, to find this simple remove
the select part and build it on again step by step.

Cor
 
Are you sure that the dataset contains records, to find this simple remove
the select part and build it on again step by step.

Cor

Actually I forgot to fill the dataset that's why it doesn't return any
records.
 
That pretty much puts you on right track everytime.

An empty dataset won't find any matches of course!

Trust me, the reason I learnt that method was because I was getting bit all
the time by any empty result set!

..................
 
Back
Top