"If at first you don't succeed; call it version 1.0" :-Unknown

Pages

Friday, November 30, 2012

Datatable with auto increment option



Datatable with auto increment option c#


        DataTable dtDuplicatelist = new DataTable();

        DataColumn auto = new DataColumn("AutoID", typeof(System.Int32));
        dtDuplicatelist.Columns.Add(auto);
        auto.AutoIncrement = true;
        auto.AutoIncrementSeed = 1;
        auto.ReadOnly = true;
        auto.Unique = true;


        dtDuplicatelist.Columns.Add("ClientID", typeof(string));
        dtDuplicatelist.Columns.Add("CurrentLoanServicer", typeof(string));
        dtDuplicatelist.Columns.Add("CurrentServicerLoanNo", typeof(string));
        dtDuplicatelist.Columns.Add("NameOfOriginatingLender", typeof(string));
        dtDuplicatelist.Columns.Add("Noofrec", typeof(string));
        dtDuplicatelist.Columns.Add("OriginalLoanNumber", typeof(string));

        dtDuplicatelist.PrimaryKey = new DataColumn[] { auto }; // Setting as primary key Then only it will add autoincrement to the Column
        return dtDuplicatelist;

 
If u had any trouble just ask, Happy to help u :)
Stay Tune... Have a nice day... 'N happy Coding :)

select records from particular week days Or datepart in sql

select records from particular week days Or datepart in sql


SELECT AgencyId,CreatedOn FROM Agencies -- List All Records

SELECT AgencyId,CreatedOn FROM Agencies WHERE (datepart (dw, CreatedOn)) IN (7,1) -- List records Only on saturday and sunday

SELECT AgencyId,CreatedOn FROM Agencies WHERE (datepart (dw, CreatedOn)) NOT IN (5,2) -- List all Records EXCEPT Thuesday and Monday
 




If u had any trouble just ask, Happy to help u :) Stay Tune... Have a nice day... 'N happy Coding :)

Wednesday, November 28, 2012

Basics Of MVC 4 Day 1

Hi *.*,
Today i'm just giving an outline about MVC 4 and Creating a sample application too.
  
ASP.NET MVC is a framework for building web applications that applies the general Model
View Controller pattern to the ASP.NET framework. The MVC separates the user interface (UI) of an application into three main aspects:


  •  The Model: A set of classes that describes the data you’re working with as well as the business rules for how the data can be changed and manipulated
  •   The View: Defines how the application’s UI will be displayed
  •    The Controller: A set of classes that handles communication from the user, overall application flow, and application-specific logic
MVC 4

As we are directly going to 4th version of MVC, we had got lot of advantage
  •  Json support
  • JavaScript support 
  • Improved Visual Studio tooling,
  • Asynchronous controllers support,
  • The Razor view engine
  • Support for .NET 4 Data Annotations
  • Improved model validation
  • Greater control and flexibility with support for dependency resolution and global action filters
  • ASP.NET Web API
  • Enhancements to default project templates
  • Mobile project template using jQuery Mobile
  • Display Modes
  • Task support for Asynchronous Controllers
  • Bundling and minification
  • Service handling
And So On… 

Tuesday, November 20, 2012

Welcome to MVC 4.



From the last few weeks I’m having huge pressure to teach MVC to my friends from my close friend. I was having heavy work pressure and late night office is my daily ways. I don’t get time that the only reason. Last day I was been trapped and I agreed. What I’m planning to teach them on coming days will be published on my blog. If u guy’s have any suggestion pls comment, so that I can also be more clear and confident about that. Welcome to MVC 4.
 



If u had any trouble just ask, Happy to help u :)
Stay Tune...
Have a nice day... 'N happy Coding :)

Sunday, November 11, 2012

Fetch data between two dates in dataview rowfilter

 Fetch data between two dates in dataview rowfilter
DateTime from = Convert.ToDateTime(txtFrom.Text);
DateTime to = Convert.ToDateTime(txtTo.Text);
string dateFilterString = "CreatedOnFilter >= #" + from + "# AND CreatedOnFilter <= #" + to + "#";



If u had any trouble just ask, Happy to help u :)
 Stay Tune...
 Have a nice day... 'N happy Coding :)

Saturday, November 10, 2012

Bulk Copy with Transaction Control in Asp.net c#


 Sample Code for Bulk Copy with Transaction Control in Asp.net c#






sqlConnection conn = db.CreateConnection();  // Create a new connection
// For Command cmd
db.AddInParameter(cmd, "@CFirstName", DbType.String, dt.Rows[i][j].ToString()); j++;
// adding new parameter Blah Blah Blah
db.AddInParameter(cmd, "@CLastName", DbType.String, dt.Rows[i][j].ToString()); j++;
// adding new parameter Blah Blah Blah
db.AddInParameter(cmd, "@CTitle", DbType.String, dt.Rows[i][j].ToString()); j++;
//adding new parameter Blah Blah Blah

SQLTransaction trx = conn.BeginTransaction(); // Begin Transcation

cmd.Transaction = trx; // Adding transcation to command
try
{
db.ExecuteNonQuery(cmd, trx); // passing transcation to sql
datatable dtdata = dataList();
System.Data.SqlClient.SqlBulkCopy oSqlBulkCopy = new System.Data.SqlClient.SqlBulkCopy((SqlConnection)trx.Connection, SqlBulkCopyOptions.TableLock, (SqlTransaction)trx);
oSqlBulkCopy.DestinationTableName = "EscalationIssues";
oSqlBulkCopy.WriteToServer(dtdata);
trx.Commit();// Commit transcation
conn.Close();
oSqlBulkCopy.Close();
}
Catch(sqlexception sqlex)
{
Trx.rollback(); // Roll back Transcation
}


Public datatable dataList()
{
DataTable dtdata = new DataTable();
dtdata.Columns.Add("EscalationIssueId", typeof(Guid));  //Primary key
dtdata.Columns.Add("EscalationId", typeof(Int32));
dtdata.Columns.Add("IssueId", typeof(Int32));
dtdata.Columns.Add("CreatedOn", typeof(DateTime));
dtdata.Columns.Add("CreatedBy", typeof(string));
for (int k = 0; k < 10; k++)
{
DataRow dr = dtdata.NewRow();
dr["EscalationIssueId"] = new Guid();
dr["EscalationId"] = Convert.ToInt32(escaltionID);
dr["IssueId"] = Convert.ToInt32(lsulist[k]);
dr["CreatedOn"] = DateTime.Now;
dr["CreatedBy"] = "Arun Aravind";
dtdata.Rows.Add(dr);
}
}

}




If u had any trouble just ask, Happy to help u :)
Stay Tune... Have a nice day... 'N happy Coding :)