Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6729187
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T10:15:34+00:00 2026-05-26T10:15:34+00:00

example of a return function that returns only string value, how do I return

  • 0

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..

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T10:15:35+00:00Added an answer on May 26, 2026 at 10:15 am

    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:

    public class Participant
    {
       public int Id { get; private set; }
       public string Name {get; set;}
       public string Address {get; set; }
    
    
       public Participant( int id, string name, string address )
       {
           this.Id = id;
           this.Name = name;
           this.Address = address;
       }
    }
    
    public Participant GetParticipant( string name )
    {
        using( var conn = new OleDbConnection (connectionString) )
        {
            using( var cmd = connection.CreateCommand() )
            {
                  command.CommandText = "SELECT [Id], [Name], [Address] FROM Participant WHERE [name] LIKE @p_name";
    
    
                   command.Parameters.Add ("@p_name", OleDbType.VarChar).Value = name + "%";
    
                   using( var reader = command.ExecuteReader() )
                   {
                        if( !reader.HasRows() ) return null;
    
                        reader.Read();
    
                        return new Participant (reader.GetString("Id"), reader.GetString("name"), reader.GetString("address"));
                   }
            }
        }
    
    }
    

    Note: there can be syntax errors, since I haven’t pulled it through the compiler, but I think you’ll catch the drift.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In python, you can have a function return multiple values. Here's a contrived example:
Here is an (artificial) example of using a function that returns an anonymous struct
Id like to make a simple function, that return value of two Strings, basically:
For example: (function() { var proxied = window.eval; window.eval = function() { return proxied.apply(this,
For example: > function foo() { > jQuery(whatever).each( function() { return; // this just
Take the following example plugin: (function($) { $.fn.alertOnClick = function(text) { return this.each(function(){ $(this).click(alert(text));
is there any example on using java method to call rhino-javascript function and return
For Example: Let's say that I want to return a view that displays a
I need a function that will take a string and pascal case it. The
I would like an algorithm for a function that takes n integers and returns

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.