example of a return function that returns only string value, how do I return multiple values consisting of different data types in a single record by simply calling one function?
public static string selectPassword(string user)
{
using (var connection = new OleDbConnection(connectionString))
using (var command = connection.CreateCommand())
{
command.Parameters.AddWithValue("@user", user);
command.CommandText = "SELECT [Password] FROM [Password_Table] WHERE Password_ID = [@user]";
command.CommandType = CommandType.Text;
connection.Open();
var value = command.ExecuteScalar();
return value == DBNull.Value ? null : value.ToString();
}
}
my record would be searched by Participant_Name, and would need to return Participant_Name, Participant_ID, Address, Contact_Number & Gender fields, all consisting of string, integers etc..
Create a data-type which consists of fields and properties that are able to hold the information that you want to retrieve.
Populate an instance of that type in your method, and return it.
Something like this, for instance:
Note: there can be syntax errors, since I haven’t pulled it through the compiler, but I think you’ll catch the drift.