Skip to content

testing

using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data;
using System.Data .SqlClient ;
using System.Web .Configuration ;

/// <summary>
/// Summary description for clsTransactiones
/// </summary>
public class clsTransactiones
{
    public SqlConnection obSqlConnection;
    public string strConString = WebConfigurationManager.ConnectionStrings["EmloyeeConnectionString"].ConnectionString;

    public SqlDataAdapter objSqlDataAdapter;
    public SqlCommandBuilder objSqlCommandBuilder;
    public SqlCommand objSqlCommand;


    public DataSet ViewData(string sql)
    {
        try
        {
            DataSet objDatset = new DataSet();
            obSqlConnection = new SqlConnection(strConString);
            objSqlDataAdapter = new SqlDataAdapter(sql, obSqlConnection);
            objSqlCommandBuilder = new SqlCommandBuilder(objSqlDataAdapter);
            objSqlDataAdapter.Fill(objDatset);
            obSqlConnection.Close();
            obSqlConnection.Dispose();
            return objDatset;
        }
        catch (Exception)
        {
            
            throw;
        }
           

    }


    public void InsertData(string sql)
    {
        try
        {
            obSqlConnection = new SqlConnection(strConString);
            objSqlCommand = new SqlCommand(sql, obSqlConnection);
            objSqlDataAdapter = new SqlDataAdapter();
            obSqlConnection.Open();

            objSqlDataAdapter.InsertCommand = objSqlCommand;
            objSqlDataAdapter.InsertCommand.ExecuteNonQuery();
            obSqlConnection.Close();
            obSqlConnection.Dispose();
        }
        catch (Exception)
        {
            
            throw;
        }     
    }

    public void   UpdateData(string sql)
    {
        try
        {
            obSqlConnection = new SqlConnection(strConString);
            objSqlCommand = new SqlCommand(sql, obSqlConnection);
            objSqlDataAdapter = new SqlDataAdapter();
            obSqlConnection.Open();

            objSqlCommand.CommandText = sql;
            objSqlDataAdapter.UpdateCommand = objSqlCommand;
            objSqlDataAdapter.UpdateCommand.ExecuteNonQuery();
            obSqlConnection.Close();
            obSqlConnection.Dispose();
        }
        catch (Exception)
        {

            throw;
        }
    }

    public void DeleteData(string sql)
    {
        try
        {
            obSqlConnection = new SqlConnection(strConString);
            objSqlCommand = new SqlCommand(sql, obSqlConnection);
            objSqlDataAdapter = new SqlDataAdapter();
            obSqlConnection.Open();

            objSqlCommand.CommandText = sql;
            objSqlDataAdapter.DeleteCommand  = objSqlCommand;
            objSqlDataAdapter.DeleteCommand.ExecuteNonQuery();
            obSqlConnection.Close();
            obSqlConnection.Dispose();
        }
        catch (Exception)
        {

            throw;
        }
    }

    // Public Sub DropReasons()

        
    //    Dim oTran As New Transactiones
    //    Dim sSql As String
    //    Dim oDataSet As DataSet

    //    Try

    //        DDLReason.Items.Clear()
    //        sSql = "SELECT * FROM TBS_REASON "
    //        oDataSet = oTran.TRNdatagrid(sSql)
    //        DDLReason.DataSource = oDataSet.Tables(0)
    //        DDLReason.DataTextField = "Reason_Desc"
    //        DDLReason.DataValueField = "Reason_Code"
    //        DDLReason.DataBind()
    //        DDLReason.Items.Insert(0, "Select a Reason")
    //        oTran.CloseGrid()

    //    Catch ex As Exception

    //        lblerror.Text = "Excpetion : " + ex.Message + "Location : DropReasons()"
    //        lblerror.Visible = True

    //    End Try
    //End Sub
}

////////////////////////////////
    protected void Button1_Click(object sender, EventArgs e)
    {

        try
        {
            DateTime DOB = DateTime.Parse(txtDOB.Text.ToString());
            objTran = new clsTransactiones();
            string strSql = "INSERT INTO EMP_Master (EmpFirstName,EmpLastName,EmpDOB)" +
                            "VALUES('" + txtFirstName.Text.ToString() + "','" + txtLastName.Text.ToString() + "','" + DOB + "')";
            objTran.InsertData(strSql);
        }
        catch (Exception ex)
        {

            DOB0.Text = ex.ToString();

        }
    
    }
    protected void Button4_Click(object sender, EventArgs e)
    { 
        DataSet  objdataset = new DataSet ();
        objTran = new clsTransactiones();
        string strSql = " SELECT         EmpFirstName,EmpLastName,EmpDOB" +
                        " FROM  EMP_Master WHERE EmpFirstName ='" + txtFirstName.Text.ToString() +"'";
        objdataset=objTran.ViewData (strSql);
        if (objdataset.Tables [0].Rows .Count >0)
        {
            txtLastName.Text =objdataset.Tables[0].Rows[0]["EmpLastName"].ToString ();
            txtDOB.Text = DateTime.Parse(objdataset.Tables[0].Rows[0]["EmpDOB"].ToString()).ToShortDateString();
           
        }
        
    }
}
Advertisements

Solution for error ” Unable to evaluate expression because the code is optimized or a native frame is on top of the call stack”

Hello world!

Welcome to WordPress.com. This is your first post. Edit or delete it and start blogging!