Click here to Skip to main content
15,887,683 members
Home / Discussions / C#
   

C#

 
GeneralRe: Language Converter Pin
Eddy Vluggen23-Sep-15 3:25
professionalEddy Vluggen23-Sep-15 3:25 
GeneralRe: Language Converter Pin
Pete O'Hanlon23-Sep-15 4:24
mvePete O'Hanlon23-Sep-15 4:24 
GeneralRe: Language Converter Pin
Ravi Bhavnani23-Sep-15 18:31
professionalRavi Bhavnani23-Sep-15 18:31 
AnswerRe: Language Converter Pin
Eddy Vluggen23-Sep-15 2:20
professionalEddy Vluggen23-Sep-15 2:20 
AnswerRe: Language Converter Pin
Ravi Bhavnani23-Sep-15 18:32
professionalRavi Bhavnani23-Sep-15 18:32 
Questionunsupported key version of Licensing.Net Pin
dinesh9122-Sep-15 20:09
dinesh9122-Sep-15 20:09 
AnswerRe: unsupported key version of Licensing.Net Pin
OriginalGriff22-Sep-15 20:28
mveOriginalGriff22-Sep-15 20:28 
QuestionQuery a DataSet C# - Array Throwing Null Error Pin
Member 1195658922-Sep-15 10:50
Member 1195658922-Sep-15 10:50 
I am making a small project to build my skills, and what I am trying to do is query a DataSet which is filled from a SQL database using a SELECT query.

However, I cannot manage to query the dataset further, I would like to be able to search the dataset and it will pull up results, this is what I have so far, though I get this error - An unhandled exception of type 'System.NullReferenceException' occurred

My table is called Animals, and I am searching in the parlour_number column.

I have searched, but I don't understand most of what I have looked at, I have a very basic understanding still.

DataSet ds;
DataRow dRow;

private void searchBtn_Click(object sender, EventArgs e)
    {
        string searchFor = tbSearch.Text;
        int results = 0;
        DataRow[] returnedRows;

        returnedRows = ds.Tables["Animals"].Select("parlour_number='" + searchFor + "'");

        results = returnedRows.Length;

        if(results > 0)
        {
            dRow = returnedRows[0];

            MessageBox.Show(dRow[1].ToString() + " " + dRow[2].ToString());
        }
        else
        {
            MessageBox.Show("No records found");
        }
    }


It breaks at the

C#
returnedRows = ds.Tables["Animals"].Select("gender='" + searchFor + "'");


and tells me that there is a Null value.

returnedRows is null, but should my query not populate it?

Thanks.
AnswerRe: Query a DataSet C# - Array Throwing Null Error Pin
Garth J Lancaster22-Sep-15 13:58
professionalGarth J Lancaster22-Sep-15 13:58 
AnswerRe: Query a DataSet C# - Array Throwing Null Error Pin
Agent__00722-Sep-15 17:11
professionalAgent__00722-Sep-15 17:11 
AnswerRe: Query a DataSet C# - Array Throwing Null Error Pin
Winner7823-Sep-15 22:52
Winner7823-Sep-15 22:52 
QuestionInheritage with multiple abstract classes Pin
TMattC22-Sep-15 8:57
TMattC22-Sep-15 8:57 
AnswerRe: Inheritage with multiple abstract classes Pin
TMattC22-Sep-15 9:24
TMattC22-Sep-15 9:24 
AnswerRe: Inheritage with multiple abstract classes Pin
BillWoodruff22-Sep-15 9:42
professionalBillWoodruff22-Sep-15 9:42 
Questionfonts are Changing alone in a strange way - Windows CE , i update my first question Pin
goldsoft22-Sep-15 2:53
goldsoft22-Sep-15 2:53 
AnswerRe: fonts are Changing alone in a strange way - Windows CE , i update my first question Pin
OriginalGriff22-Sep-15 3:00
mveOriginalGriff22-Sep-15 3:00 
GeneralRe: fonts are Changing alone in a strange way - Windows CE , i update my first question Pin
goldsoft22-Sep-15 4:15
goldsoft22-Sep-15 4:15 
GeneralRe: fonts are Changing alone in a strange way - Windows CE , i update my first question Pin
OriginalGriff22-Sep-15 4:24
mveOriginalGriff22-Sep-15 4:24 
AnswerRe: fonts are Changing alone in a strange way - Windows CE , i update my first question Pin
Pete O'Hanlon22-Sep-15 4:49
mvePete O'Hanlon22-Sep-15 4:49 
QuestionHow to remain WPF Window always on top of all windows? Pin
Benjamin.Buhr22-Sep-15 1:06
Benjamin.Buhr22-Sep-15 1:06 
AnswerRe: How to remain WPF Window always on top of all windows? Pin
Eddy Vluggen22-Sep-15 1:15
professionalEddy Vluggen22-Sep-15 1:15 
GeneralRe: How to remain WPF Window always on top of all windows? Pin
Benjamin.Buhr22-Sep-15 1:36
Benjamin.Buhr22-Sep-15 1:36 
GeneralRe: How to remain WPF Window always on top of all windows? Pin
Eddy Vluggen22-Sep-15 2:12
professionalEddy Vluggen22-Sep-15 2:12 
GeneralRe: How to remain WPF Window always on top of all windows? Pin
Benjamin.Buhr24-Sep-15 1:09
Benjamin.Buhr24-Sep-15 1:09 
GeneralRe: How to remain WPF Window always on top of all windows? Pin
Eddy Vluggen24-Sep-15 1:20
professionalEddy Vluggen24-Sep-15 1:20 

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.