1 Replies - 181 Views - Last Post: 05 February 2012 - 08:08 AM Rate Topic: -----

Topic Sponsor:

#1 ee_persian  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 22-January 12

how do get this return value

Posted 04 February 2012 - 05:46 PM

hi all
i want have a one form to always return columns[0] of selected row .
intermediate method is ReturnAllCode...s
i writed a public method ReturnAllCodes that I want always return Columns[0] Of selected Rows form form that i want ...

public int ReturnAllCodes(string WinTitle, string Query, string[] Fields, string RequestCode)
        {
            all_codes _all_code = new all_codes();
            _all_code.Text = WinTitle;
            _all_code.dgv_all.DataSource = SelectAllQuery(Query);
 
            for (int i = 0; i < Fields.Length; i++)
            {
                _all_code.dgv_all.Columns[i].HeaderText = Fields[i];
            }
 
            _all_code.ShowDialog();
 
            if (_all_code.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
 
            }
 
            return 0;
        }




Notics : all_codes Is A From That Contain Only One Datagrid

I send my parameter to this method without problem ...

But For Get The Return Value I Have A problem that Is Cant Write Code For return Value ...

i means : how Do Return The Columns[0] of Selected Row in all_codes To Method ReturnAllCodest ???

this is a SelectAllQuery Method that No Problem (i Show it Only For Better Question)


public  DataTable SelectAllQuery(String _query)
        {
            SqlConnection Mycon = new SqlConnection(strconnection);
            SqlCommand myCommand = new SqlCommand();
            myCommand.Connection = Mycon;
            SqlDataAdapter myAdapter = new SqlDataAdapter();
            DataTable dataTable = new DataTable();
            dataTable = null;
            DataSet ds = new DataSet();
            try
            {
                myCommand.CommandText = _query;
 
                if (Mycon.State != ConnectionState.Open)
                {
                    Mycon.Open();
                }
                
                myCommand.ExecuteNonQuery();
                myAdapter.SelectCommand = myCommand;
                myAdapter.Fill(ds);
                dataTable = ds.Tables[0];
                
                if (Mycon.State != ConnectionState.Closed)
                {
                    Mycon.Close();
                }
            }
            catch (SqlException e)
            {
                return null;
            }
            finally
            {
 
            }
            return dataTable;
        }



Help Me Please
TNKs

Is This A Good Question/Topic? 0
  • +

Replies To: how do get this return value

#2 tlhIn`toq  Icon User is online

  • WillMyCodeWork = !FailedWhenYouTriedIt;
  • member icon

Reputation: 3291
  • View blog
  • Posts: 6,899
  • Joined: 02-June 10

Re: how do get this return value

Posted 05 February 2012 - 08:08 AM

Its really hard to follow what you are saying. The meaning of most of your sentences is lost is translation.

Quote

But For Get The Return Value I Have A problem that Is Cant Write Code For return Value ...


Are you saying your code produces an error, when you try to return the value? Please post the actual error without rephrasing it. And show us which line has the error.

A screen capture might be easiest.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1