Avatar of R8VI
R8VI

asked on 

c# datable display data

HI,

I have the below code I am operating a 3 tier Arch, with presentation, business, and data layer.

I am getting a value Ifrom the DB I need to know how to display the value in the label

Please help

Thanks,

R8VI
Data Layer

 public DataTable LoadPropertyId(string sPropertyNumber, string sStreetName)

        string connStr = ConfigurationManager.ConnectionStrings["SplitfeeConnString"].ToString();
        SqlConnection conn = new SqlConnection(connStr);
        conn.Open();
        SqlCommand cmd = new SqlCommand("spGetPID", conn);
        cmd.CommandType = CommandType.StoredProcedure;


        DataTable DTpropID = new DataTable();

        try
        {

            cmd.Parameters.AddWithValue("@PropertyNumber", sPropertyNumber);
            cmd.Parameters.AddWithValue("@StreetName", 


            // Create new DataAdapter
            using (SqlDataAdapter sqlDataAdptGetPropertyID = new SqlDataAdapter("sp", conn))
            {

                sqlDataAdptGetPropertyID.Fill(DTpropID);


            }
        }
        catch
        {
            throw;
        }

        finally
        {
            cmd.Dispose();
            conn.Close();
            conn.Dispose();
        }

        return DTpropID; 

    }

Business layer

public DataTable LoadPropertyIdBAL(string sPropertyNumber, string sStreetName)
    {

        DataTable DTpropIDBAL = new DataTable();

        GetPropertyInfoDAL DataTablePropertyID = new GetPropertyInfoDAL();

        try
        {
            DataTablePropertyID.LoadPropertyId(sPropertyNumber, sStreetName);
        }
        catch
        {
            throw;
        }


        return DTpropIDBAL;
    }

Presentention layer

string sPropertyNumber = txtPropertyNumber.Text;
            string sStreetName = txtStreet.Text;
         

            GetPropertyInfoBAL PropertyID = new GetPropertyInfoBAL();

            PropertyID.LoadPropertyIdBAL(sPropertyNumber, sStreetName);

//need to display what is in the datatable in this text box             
            lblPropertyID.Text = "";

Open in new window

.NET ProgrammingASP.NETC#

Avatar of undefined
Last Comment
starlite551

8/22/2022 - Mon