Click here to Skip to main content
15,901,205 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
//this is my BusinessLayer in a form of class (DataAccessLayer)
//i have a class called Property and DataAccessLayer called BusinessLayer
//and again i have store procedure on a sqlDtatabase called allOfProparty

public DataTable AllofProperty()
        {
            using (SqlConnection sqlConn = new SqlConnection(ConnectionString))
            {
                SqlCommand sqlCmd = new SqlCommand("allOfProparty", sqlConn);
                sqlCmd.CommandType = CommandType.StoredProcedure;

                SqlDataAdapter sqlAdapter = new SqlDataAdapter(sqlCmd);

                DataTable ds = new DataTable();

                try
                {
                    sqlConn.Open();
                    sqlAdapter.Fill(ds);
                }
                catch (SqlException ex)
                {
                    throw new Exception(ex.Message);

                }
                return ds;
            }
        }


i have a WPF form with a comboBox so i want to load propertyNo to comboBox

please help
Posted

1 solution

First return ds.table[0] instead of return ds;
C#
DataAccessLayer da = new DataAccessLayer();
cmb_propertyNo.ItemsSource = (from n in da.AllofProperty.AsEnumerable()select n).ToList();
cmb_propertyNo.DisplayMemberPath="propertyNo";
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900