We help IT Professionals succeed at work.
Get Started

c# datable display data

R8VI
R8VI asked
on
302 Views
Last Modified: 2012-05-11
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

Comment
Watch Question
This problem has been solved!
Unlock 1 Answer and 8 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE