Showing posts with label DAL. Show all posts
Showing posts with label DAL. Show all posts

Wednesday, May 30, 2012

Saving Date Using Microsoft SQL Helper Class


Saving Date Using Microsoft SQL Helper Class
   
First Import  :-   Imports Microsoft.ApplicationBlocks.Data

Private Sub SaveData()
        Dim param(12) As SqlParameter
        param(0) = New SqlParameter("@patient_Id", sCookPatMrn)
        param(1) = New SqlParameter("@eventId", sCookPatVisit)
        param(2) = New SqlParameter("@created_User", sCookPatMrn)
        param(3) = New SqlParameter("@modified_User", sCookPatMrn)
        param(4) = New SqlParameter("@VoidedVol", Int32.Parse(txtVoided.Text))
        param(5) = New SqlParameter("@MaxRate", Int32.Parse(txtMaxRate.Text))
        param(6) = New SqlParameter("@PVR", Int32.Parse(txtPVR.Text))
        param(7) = New SqlParameter("@Sensation", Int32.Parse(txtSensation.Text))
        param(8) = New SqlParameter("@MaxCapacity", Int32.Parse(txtMaxCapacity.Text))
        param(9) = New SqlParameter("@VoidingPressureAvg", Int32.Parse(txtPressureAvg.Text))
        param(10) = New SqlParameter("@VoidingPressureIso", Int32.Parse(txtPressureISO.Text))
        param(11) = New SqlParameter("@id", SqlDbType.Int, 0, ParameterDirection.Output, False, 0, 0, "ID", DataRowVersion.Default, Nothing)
        '' param(12) = New SqlParameter("@masterGroup", "CystoProstate")
      SqlHelper.ExecuteNonQuery(dbconn, CommandType.StoredProcedure, "Put_StoreProcedure_Name", param)
        If (IsDBNull(param(11).Value) = False) Then
            _cystoInstrumId = param(11).Value
        End If

    End Sub

Tuesday, November 15, 2011

Data Access Layer (DAL Example) in ASP.NET (C#)

DAL Example


DAL resides in appcode folder.It is a simple C# class.

Create a new folder name it appcode & now add a new C# class in it & write code for database connectivity.

//Import Required Namespace Here
public class       CALLConnection
{
    SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["con"].ConnectionString);
    public WisemiserSMS()
    {

    }
    #region properties

    string _phoneNumber;
    public string PhoneNumber { get { return _phoneNumber; } set { _phoneNumber = value; } }
    int _msgId;
    public int MessageId { get { return _msgId; } set { _msgId = value; } }
    int _userId;
    public int UserId { get { return _userId; } set { _userId = value; } }
    string _messageText;
    public string MessageText { get { return _messageText; } set { _messageText = value; } }
    DateTime _sentTime;
    public DateTime SentTime { get { return _sentTime; } set { _sentTime = value; } }
    string _userName;
    public string UserName { get { return _userName; } set { _userName = value; } }
    string _password;

 
    #endregion

    public void sentSMSFlag()
    {
    openConnection();
        DataSet ds = new DataSet();
        SqlCommand cmd = new SqlCommand("sp_smsSentFlag", con);
 
        cmd.CommandType = CommandType.StoredProcedure;
        cmd.Parameters.AddWithValue("@id", this.id);
        //cmd.Parameters.AddWithValue("@raiseflag", this.addedtime);

        cmd.ExecuteNonQuery();
        con.Close();
        cmd.Dispose();
    }
}


Now we can call it in our code like this  CALLConnection.sentSMSFlag()