Skip to main content

Posts

Showing posts from May, 2014

How to use transaction in sqlbulk in asp.net

There are many situation where you need to use transactions in order to avoid incorrect updation or half updation in the database.SO we use transaction that either all data updated or nothing will effect. Here is the code :  SqlTransaction trans;         if (con.State == ConnectionState.Closed)             con.Open();         trans = con.BeginTransaction();         try         {             DataTable dtCourses = new DataTable();             dtCourses.Columns.Add(new DataColumn("RegistrationNumber", typeof(long)));             dtCourses.Columns.Add(new DataColumn("CurrentTerm", typeof(string)));             dtCourses.Columns.Add(new DataColumn("RegistrationForTerm", typeof(string)));             dtCourses.Columns.Add(new DataColumn("RegistrationStatus", typeof(string)));             dtCourses.Columns.Add(new DataColumn("AmountPaid", typeof(int)));             dtCourses.Columns.Add(new DataColumn("DDNumber", typeof(string)))

Search Radio button or Any control in Radgrid telerik

Here is the code :  string msg = "";         if (RadGrid1.MasterTableView.Items.Count > 0)         {             foreach (GridDataItem item in RadGrid1.MasterTableView.Items)             {                 if ((item.FindControl("RadioButtonList1") as RadioButtonList).SelectedValue.ToString() == "Continue")                 {                     if ((item.FindControl("txtamount") as TextBox).Text == "" || (item.FindControl("txtddamount") as TextBox).Text == "" || (item.FindControl("txtddnumber") as TextBox).Text == "" || (!(item.FindControl("rdpdddate") as RadDatePicker).SelectedDate.HasValue) || (item.FindControl("txtbankname") as DropDownList).SelectedItem.ToString() == "--na--")                     {                         msg = "Please Enter DD Details for Reg No " + (item.FindControl("RegisterationNumberLabel") as Label).Text;             

Clear all textboxes in csharp in asp.net

Code :    public void ClearControls(Control c)     {         foreach (Control c1 in c.Controls)         {             if (c1.GetType() == typeof(TextBox))             {                 ((TextBox)c1).Text = "";             }             if (c1.HasControls())             {                 ClearControls(c1);             }         }     } ClearControls(Page);

How to add new Column in excel File using oledb in .net

Here is the code :-   OleDbConnection vConn = new OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=E:\\information.xls;Extended Properties=Excel 12.0");             vConn.Open();             try             {                 String rQLlll = "DROP TABLE NewTempTable ;";                 OleDbCommand mdd = new OleDbCommand(rQLlll, vConn);                 mdd.ExecuteNonQuery();             }             catch             {             }             String strSQL = "SELECT NULL as thuluuuuu,* INTO NewTempTable FROM [data$];";             OleDbCommand cmd = new OleDbCommand(strSQL, vConn);             cmd.ExecuteNonQuery();             try             {                 String strSQLl = "DROP TABLE [data$];";                 OleDbCommand cmdd = new OleDbCommand(strSQLl, vConn);                 cmdd.ExecuteNonQuery();                 String rSQLlll = "DROP TABLE data ;";                 OleDbCommand mddd =

convert data table to excel in csharp.net

function to convert :-  protected void UploadDataTableToExcel(DataTable dtEmp, string filename)     {         string attachment = "attachment; filename=" + filename;         Response.ClearContent();         Response.AddHeader("content-disposition", attachment);         Response.ContentType = "application/vnd.ms-excel";         string tab = string.Empty;         foreach (DataColumn dtcol in dtEmp.Columns)         {             Response.Write(tab + dtcol.ColumnName);             tab = "\t";         }         Response.Write("\n");         foreach (DataRow dr in dtEmp.Rows)         {             tab = "";             for (int j = 0; j < dtEmp.Columns.Count; j++)             {                 Response.Write(tab + Convert.ToString(dr[j]));                 tab = "\t";             }             Response.Write("\n");         }         Response.End();     }

Know About Stolen Phone while buying second hand mobile phone

Do you want to track your new second hand mobile phone whether it is stolen or not .Some people sell stolen mobile phone for their benefits But this may cause problem if you buy that phone. So you can know about it that whether it is stolen or not by just one click Visit  HERE  and Enter IMEI code for mobile that you want to buy and it will show you about its stolen history. Thanks

Print Datatable in C sharp(C#) .net windows Application

CODE :   private void btnprint_Click(object sender, EventArgs e)         {       PrintDocument document = new PrintDocument();             document.PrintPage += new PrintPageEventHandler(document_PrintPage);             PrintPreviewDialog ppDialog = new PrintPreviewDialog();             ppDialog.Document = document;             ppDialog.Show();         }  void document_PrintPage(object sender, PrintPageEventArgs e)         {             PrintDocument document = (PrintDocument)sender;             Graphics g = e.Graphics;             Brush brush = new SolidBrush(Color.Black);             Pen pen = new Pen(brush);             Font font = new Font("Arial", 10,FontStyle.Bold);             Font fonte = new Font("Arial", 15, FontStyle.Bold);             int x = 0, y = 0, width = 200, height = 30;             SizeF sizeeee = g.MeasureString("TIME :: ", fonte);             float xPaddingeee = (width - sizeeee.Width) / 2;             g.DrawString("TIME

25 Things That Happen To You In Your Mid-Twenties (lol)

Some things only unfold with time. The moment you realize you’ve seen it all, unexpected things happen. But again, life would be boring otherwise. Fasten your seat-belts and wear a helmet. The road’s gonna get messy! 1. You will realize why Friday is the best day of the week Source 2. And, Monday the worst Source 3. You will understand why LinkedIn exists Source ..and probably spend some time ‘endorsing’ rather than ‘liking’. 4. Be sorry for not getting serious with the right person Source ..at the right time.  5. What happens when you leave your computer unlocked at office You never valued the lock screen until you met prankster co-workers. 6. You will be in the wrong industry (or have a degree in something you hate) Worry not, you’re not alone. Even Sachin wanted to be a Tennis player. 7. Facebook will be filled with engagement and marriage pics ..and those honeymoon pics we never asked for. 8. And when you will