Click here to Skip to main content
15,911,786 members
Home / Discussions / C#
   

C#

 
AnswerRe: What is Constructor Overloading in C# .net ? Pin
OriginalGriff26-Apr-15 21:28
mveOriginalGriff26-Apr-15 21:28 
AnswerRe: What is Constructor Overloading in C# .net ? Pin
Dr Gadgit27-Apr-15 3:43
Dr Gadgit27-Apr-15 3:43 
AnswerRe: What is Constructor Overloading in C# .net ? Pin
David A. Gray3-May-15 10:19
David A. Gray3-May-15 10:19 
QuestionVideo cutter / merger in C# winfrom Pin
Member 1162007426-Apr-15 7:35
Member 1162007426-Apr-15 7:35 
GeneralRe: Video cutter / merger in C# winfrom Pin
Sascha Lefèvre26-Apr-15 7:46
professionalSascha Lefèvre26-Apr-15 7:46 
QuestionSql Dependency onchange event not firing every time c# Pin
Tridip Bhattacharjee25-Apr-15 9:56
professionalTridip Bhattacharjee25-Apr-15 9:56 
AnswerRe: Sql Dependency onchange event not firing every time c# Pin
Dave Kreskowiak25-Apr-15 10:55
mveDave Kreskowiak25-Apr-15 10:55 
Questionc# opening database to array Pin
ruspj25-Apr-15 8:03
ruspj25-Apr-15 8:03 
hey guys Smile | :)
trying to convert an access database to array to sort it by a calculated value.
the database connection is working frin in other functions
i keep getting the error message refering to the reader.GetString lines

An unhandled exception of type
'System.InvalidOperationException' occurred in System.Data.dll

Additional information: No data exists for the row/column.

can anyone help

static void displayinarray()
{
    int rows = 0;
    int averagewins;
    //in global     static OleDbConnection connection;
    //in main       connection = new OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=F:\\connected\\users.accdb");
    try
    {
        OleDbCommand command = new OleDbCommand("select * from users", connection);
        connection.Open();
        OleDbDataReader reader = command.ExecuteReader();
        while (reader.Read()) {rows++;};
        string[,] results = new string[6,rows];
        for (int loop = 0; loop <= rows; loop++)
        {
            results[0,loop] = reader.GetString(0);
            results[1,loop] = reader.GetString(1);
            results[2,loop] = reader.GetString(2);
            results[3,loop] = reader.GetInt32(3).ToString();
            results[4,loop] = reader.GetInt32(4).ToString();
            averagewins = (reader.GetInt32(4) / reader.GetInt32(3))*100;
            results[5,loop] = Convert.ToString(averagewins);
        }

        Console.Clear();
        Console.WriteLine("{0}", rows);
        Console.WriteLine("  ┌──────────────┬──────────────┬──────────────┬────────┬────────┬─────────┐");
        Console.WriteLine("  │ username     │ name         │ surname      │ played │ won    │ % won   │");
        Console.WriteLine("  ├──────────────┼──────────────┼──────────────┼────────┼────────┼─────────┤");

            for (int loop = 0; loop <= rows ; loop++)
        {
            Console.SetCursorPosition(2, loop + 4);
            Console.WriteLine("│ {0} ", results[0,loop]);
            Console.SetCursorPosition(17, loop + 4);
            Console.WriteLine("│ {0} ", results[1,loop]);
            Console.SetCursorPosition(32, loop + 4);
            Console.WriteLine("│ {0} ", results[2,loop]);
            Console.SetCursorPosition(47, loop + 4);
            Console.WriteLine("│ {0} ", results[3,loop]);
            Console.SetCursorPosition(56, loop + 4);
            Console.WriteLine("│ {0} ", results[4,loop]);
            Console.SetCursorPosition(65, loop + 4);
            Console.WriteLine("│ {0} ", results[5,loop]);
            Console.SetCursorPosition(75, loop + 4);
            Console.WriteLine("│");
        }
        Console.WriteLine("  └──────────────┴──────────────┴──────────────┴────────┴────────┴─────────┘");

        reader.Close();
        connection.Close();
    }
    catch (OleDbException e)
    {
        Console.WriteLine("error: {0}", e.Errors[0].Message);
    }
    Console.ReadLine();
}}


modified 25-Apr-15 14:10pm.

AnswerRe: c# opening database to array Pin
Sascha Lefèvre25-Apr-15 8:16
professionalSascha Lefèvre25-Apr-15 8:16 
GeneralRe: c# opening database to array Pin
ruspj25-Apr-15 8:31
ruspj25-Apr-15 8:31 
GeneralRe: c# opening database to array Pin
Sascha Lefèvre25-Apr-15 8:50
professionalSascha Lefèvre25-Apr-15 8:50 
GeneralSharpDevolp 4.3 Pin
Member 465445225-Apr-15 3:41
Member 465445225-Apr-15 3:41 
GeneralRe: SharpDevolp 4.3 Pin
Eddy Vluggen25-Apr-15 7:32
professionalEddy Vluggen25-Apr-15 7:32 
QuestionRegistering SQL Dependency again from onchange event Pin
Tridip Bhattacharjee24-Apr-15 4:48
professionalTridip Bhattacharjee24-Apr-15 4:48 
QuestionSql Dependency onchange event not firing every time c# Pin
Tridip Bhattacharjee24-Apr-15 3:48
professionalTridip Bhattacharjee24-Apr-15 3:48 
QuestionUnable to connect Oracle database from C# Pin
meeram3924-Apr-15 3:47
professionalmeeram3924-Apr-15 3:47 
AnswerRe: Unable to connect Oracle database from C# Pin
Dave Kreskowiak24-Apr-15 4:03
mveDave Kreskowiak24-Apr-15 4:03 
GeneralRe: Unable to connect Oracle database from C# Pin
meeram3924-Apr-15 14:53
professionalmeeram3924-Apr-15 14:53 
GeneralRe: Unable to connect Oracle database from C# Pin
Dave Kreskowiak24-Apr-15 17:21
mveDave Kreskowiak24-Apr-15 17:21 
GeneralRe: Unable to connect Oracle database from C# Pin
meeram3924-Apr-15 19:28
professionalmeeram3924-Apr-15 19:28 
GeneralRe: Unable to connect Oracle database from C# Pin
meeram3925-Apr-15 0:39
professionalmeeram3925-Apr-15 0:39 
GeneralRe: Unable to connect Oracle database from C# Pin
Dave Kreskowiak25-Apr-15 3:42
mveDave Kreskowiak25-Apr-15 3:42 
GeneralRe: Unable to connect Oracle database from C# Pin
meeram3925-Apr-15 5:46
professionalmeeram3925-Apr-15 5:46 
QuestionHow to Open the Docx File in Silverlight Pin
Hrishikesh Shivacharan24-Apr-15 1:17
Hrishikesh Shivacharan24-Apr-15 1:17 
AnswerRe: How to Open the Docx File in Silverlight Pin
Dave Kreskowiak24-Apr-15 3:37
mveDave Kreskowiak24-Apr-15 3:37 

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.