1
Reply

Requesting you to modify my code

India Programmer

India Programmer

Sep 7 2010 3:38 AM
1.4k

Hi,

Suppose using three tier architecture inserting four fields in patient table. Patient id is the primary key. Using  this  key I want to get data from table using three tier architecture and those to be displayed in textbox1, textbox2, textbox3 etc. I am using stored procedure to get query. Pls some body help me. 

 

Here is my all the all the layer code:

DAL:

Public class PatientDAL

{

string connStr = ConfigurationManager.ConnectionStrings["Constring"].ToString();

public DataSet GetpatientById(string patientid)

    {

 

        SqlConnection conn = new SqlConnection(connStr);

        conn.Open();

        //SqlConnection oConnection = GetConnection();

        // build the command

        SqlCommand oCommand = new SqlCommand("GetpatientByid ", conn);

        oCommand.CommandType = CommandType.StoredProcedure; // Parametrs

        SqlParameter parapatientid = new SqlParameter("@patientid ", SqlDbType.VarChar, 15);

       parapatientid.Value = patientid;

        oCommand.Parameters.Add(parapatientid);      

        // Adapter and DataSet

        SqlDataAdapter oAdapter = new SqlDataAdapter();

        oAdapter.SelectCommand = oCommand;

        DataSet oDataSet = new DataSet();

        try

        {

            conn.Open();

            oAdapter.Fill(oDataSet, "patientDetails");

            return oDataSet;

        }

        catch (Exception oException)

        {

 

            throw oException;

        }

        finally

        {

            conn.Close();

        }

}

BAL  Class:

Public PatientBAL

{

public DataSet GetPatientById(string patientid)

    {

        PatientDAL  pDal = new PatientDAL ();

        return pDal. GetPatientById (patientid);

 

    }

}

GUI layer:

protected void TextBox1_TextChanged(object sender, EventArgs e)

    {

        string patientid = TextBox1.Text;

        patientBAL  pb = new patientBAL ();

        pb.Get patient ById(patientid);      

 

Note: Here how can I display all the necessary field in corresponding text box. Pls somebody help me……

    }


Answers (1)