Click here to Skip to main content
15,914,419 members
Home / Discussions / C#
   

C#

 
AnswerRe: C# UserControl Inheritance Pin
didydj28-Sep-15 4:07
didydj28-Sep-15 4:07 
Question(Selenium web driver using c#)How to make the webdrivers.exe path to environment varibales in my local machine Pin
Member 1200855524-Sep-15 0:47
Member 1200855524-Sep-15 0:47 
AnswerRe: (Selenium web driver using c#)How to make the webdrivers.exe path to environment varibales in my local machine Pin
Pete O'Hanlon24-Sep-15 0:54
mvePete O'Hanlon24-Sep-15 0:54 
QuestionNewbie: code doesn't return result, could someone please help? Pin
Member 1200834023-Sep-15 23:41
Member 1200834023-Sep-15 23:41 
AnswerRe: Newbie: code doesn't return result, could someone please help? Pin
OriginalGriff24-Sep-15 0:14
mveOriginalGriff24-Sep-15 0:14 
QuestionRe: Newbie: code doesn't return result, could someone please help? Pin
Richard MacCutchan24-Sep-15 1:13
mveRichard MacCutchan24-Sep-15 1:13 
QuestionMAKE AUTOMATIC NUMBER Pin
Saepul Bahri23-Sep-15 17:28
Saepul Bahri23-Sep-15 17:28 
AnswerRe: MAKE AUTOMATIC NUMBER Pin
Pete O'Hanlon23-Sep-15 21:09
mvePete O'Hanlon23-Sep-15 21:09 
AnswerRe: MAKE AUTOMATIC NUMBER Pin
OriginalGriff23-Sep-15 21:48
mveOriginalGriff23-Sep-15 21:48 
QuestionVIEW DATA FROM DATABASE Pin
Saepul Bahri23-Sep-15 17:24
Saepul Bahri23-Sep-15 17:24 
AnswerRe: VIEW DATA FROM DATABASE Pin
aarif moh shaikh23-Sep-15 19:24
professionalaarif moh shaikh23-Sep-15 19:24 
QuestionColor Calculation Pin
RadioButton23-Sep-15 13:27
RadioButton23-Sep-15 13:27 
AnswerRe: Color Calculation Pin
Ravi Bhavnani23-Sep-15 18:29
professionalRavi Bhavnani23-Sep-15 18:29 
QuestionLanguage Converter Pin
vish_jani23-Sep-15 1:51
vish_jani23-Sep-15 1:51 
AnswerRe: Language Converter Pin
Pete O'Hanlon23-Sep-15 2:29
mvePete O'Hanlon23-Sep-15 2:29 
GeneralRe: Language Converter Pin
Vish_jani23-Sep-15 3:13
Vish_jani23-Sep-15 3:13 
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 

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.