Hi @BenTam-3003 , Welcome to Microsoft Q&A,
CS1503 Argument 1: cannot convert from 'string' to 'System.Data.SqlClient.SqlCommand'
You need to modify it like below:
string PreSelectQry = "Select top 1 StudentID from student order by " + (cStudentID == "0" ? "StudentID" : "EngName, StudentID");
SqlCommand command = new SqlCommand(PreSelectQry, connection);
SqlDataAdapter adapter = new SqlDataAdapter(command);
Best Regards,
Jiale
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.