How to fix the errors

BenTam 1,781 Reputation points
2021-10-24T14:03:32.953+00:00

The captured code is in the early stage and far from finished. Since the number of students is large, the captured code does the following jobs.

  1. Shows 14 students in a DataListView which is a subclass of ObjectListView
  2. When the user press a key, there will be a routine issues the select statement
        int Z_rows = 14  
     "SELECT Top " + Z_rows.ToString() + " StudentID,Surname,GivenName,MiddleName,ChiName,Remarks "  
            + "FROM Student "  
            + "Where Cast(Surname as char(50))+Cast(GivenName as char(50))+Cast(MiddleName as char(50![143110-program.gif][1]))+Cast(StudentID as char(10))>'"  
            + M_Surname + M_GivenName + M_MiddleName + M_StudentID.PadLeft(10) + "' "  
            + "Order by Surname,GivenName,MiddleName,StudentID";  
    
    Indexes  
    Surname, GivenName, MiddleName, StudentID  
    

So that when a new student is added into the table, the student will be found immediately.

However, error is found at line 40. Grateful if any body can tell me how to fix it.

TIA

143183-program.gif

Developer technologies | C#
{count} votes

Accepted answer
  1. P a u l 10,761 Reputation points
    2021-10-24T14:41:10.633+00:00

    Is your error by chance a stack overflow exception? You're calling your String method on line 40 and that calls itself. Is that method supposed to repeat the v1 string v2 times? If so try using this instead:

    private string String(string v1, int v2) {
        return string.Join("", Enumerable.Repeat(v1, v2));
    }
    

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.