Skip to main content

Posts

Showing posts from February, 2012

Code to concatenate multiple cells in a range using excel macro

Code to concatenate multiple cells in a range using excel macro Sub Combine_Multiple_Cells() On Error Resume Next Application.DisplayAlerts = False Dim Myrange As Range Dim mydelim As String Dim Combine As String Dim eachcell As Range Dim getvalue As Range Set Myrange = Application.InputBox(Prompt:="Please select a range with your Mouse to be Concatenated.", Title:="dseri", Type:=8) On Error GoTo 0 If Myrange Is Nothing Then Exit Sub Else mydelim = Application.InputBox(Prompt:="Please enter a Delimiter.", Title:="Tejas Gandhi") For Each eachcell In Myrange Combine = Combine & mydelim & eachcell.Text Next eachcell Set getvalue = Application.InputBox(Prompt:="Select a Cell where you want the Combination.", Title:="dseri", Type:=8) getvalue = Right(Combine, Len(Combine) - 1) End If End Sub One more option is there to create a User Defined Function (UDF) ...

Excel Macro to paste all the images in excel book one after the other

Excel Macro to paste all the images in excel book one after the other Dim MyFolder As String, fn As String, i As Long MyFolder = "C:\Pictures\" If Right$(MyFolder, 1) <> "\" Then MyFolder = MyFolder & "\" fn = Dir(MyFolder & "*.jpg") i = 2 Do While fn <> "" Set p = ActiveSheet.Pictures.Insert(MyFolder & fn) p.Top = i i = i + p.Height + 5 fn = Dir() Loop End Sub

Retrive image from database and open in new page using asp.net

Retrive image from database and open in new page using asp.net MemoryStream mstream = new MemoryStream(); SqlConnection conn = new SqlConnection("Data Source=(local)\\sqlexpress;Initial Catalog=master;Integrated Security=True"); conn.Open(); SqlCommand cmd = new SqlCommand("select Image from student1 where Id=" + TextBox1.Text, conn); byte[] image = (byte[])cmd.ExecuteScalar(); mstream.Write(image, 0, image.Length); Bitmap bitmap = new Bitmap(mstream); Response.ContentType = "image/gif"; bitmap.Save(Response.OutputStream, ImageFormat.Gif); conn.Close(); mstream.Close();

C Sharp code for Sending an email

C# code for Sending an email private void send_mail() { MailMessage mm = new MailMessage("write_emailid_reciever", txtEmailId.Text); mm.Subject = "Thnaks for your Feedback."; mm.Body = "Dear Costomer Thanks for your feedback.You are more than welcome to give us a try again. Thank you."; SmtpClient sc = new SmtpClient("mailing_server", 25);//25-is smtp port number NetworkCredential nc = new NetworkCredential(); nc.UserName = "write_emailid_sender"; nc.Password = "password"; sc.Credentials = nc; sc.Send(mm); }

code for resize image in ASP.NET while uploading an image

code for resize image in ASP.NET while uploading an image public bool SaveThumbnailImage(System.Web.UI.WebControls.FileUpload fu, string FullSavePath, int HeightMax, int WidthMax) { try { if (fu.HasFile) { string tmpSaveDir = pg.Server.MapPath("~/TempUploads/"); if (System.IO.Directory.Exists(tmpSaveDir) == false) { System.IO.Directory.CreateDirectory(tmpSaveDir); } string tmpSavePath = pg.Server.MapPath("~/TempUploads/" + fu.FileName); if (System.IO.File.Exists(tmpSavePath)) { try { System.IO.File.Delete(tmpSavePath); } catch { } } fu.SaveAs(tmpSavePath); System.Drawing.Image img = System.Drawing.Image.FromFile(tmpSavePath); double ratioWidth = (double)img.Width / (double)WidthMax; double ratioHeight = (double)img.Height / (double)HeightMax; double ratio = Math.Max(ratioHeight, ratioWidth); int newWidth = (int)(img.Width / ratio); int newHeight = (int)(img.Height / ratio); ...

C Sharp code for encription and decription of password or text

C# code of encription and decription following are two functions. one for encryption and second for decryption. textbox3 is text box to input data and textbox4 is textbox shows encrypted data. private void encrypt() { int i = 0; string result = ""; string old = textBox3.Text; do { result = result + Convert.ToChar(Convert.ToInt32(old) + (i + 2)); i = i + 1; } while (i < old.Length); textBox4.Text = result; textBox3.Text =""; } private void decrypt() { int i = 0; string result = ""; string old = textBox4.Text; do { result = result + Convert.ToChar(Convert.ToInt32(old) - (i + 2)); i = i + 1; } while (i < old.Length); textBox3.Text = result; textBox4,Text=""; }

How to send data at Business Logic layer by repository pattern

Core--> interfaces, entities, helpers, constants etc Data-->responsible for fetching data from DB. mostly returns Data Table Data Sets--> if m using LINQ, this would be the Data Context Service--> Converts Data Table etc into Entities . Application --> Knows how to deal with entities . show them manipulate them send them back and forth .  insert data using Service layer . If you  find this pattern more flexible .. you could write multiple Data layers that could fetch data from more than one kind of DB and use what you want. If you want to write Data layer that targets more than one kind of DB types (Oracle, Sql, MySql) with little code change then you can use the provider pattern.

Change textbox color if textbox is empty in asp.net using c#

Change textbox color if textbox is empty in asp.net using c# private void button1_Click(object sender, EventArgs e) { textBox1.BackColor = Color.White; textBox2.BackColor = Color.White; textBox3.BackColor = Color.White; textBox4.BackColor = Color.White; string[] text = new string[4]; text[0] = System.Convert.ToString(textBox1.Text); text[1] = System.Convert.ToString(textBox2.Text); text[2] = System.Convert.ToString(textBox3.Text); text[3] = System.Convert.ToString(textBox4.Text); for (int i = 0; i <= 3; i++) { if (text == "") { errorshow(i); } } } private void errorshow(int k) { switch (k) { case 0: textBox1.BackColor = Color.Red; break; case 1: textBox2.BackColor = Color.Red; break; case 2: textBox3.BackColor = Color.Red; break; case 3: textBox4.BackColor = Color.Red; break; } }

How to call a report designer at runtime

How to call a report designer at runtime Crystal Report is built in object of VS. You can find it from toolbar. Drag Crystal report viewer and drop it on your form. Crystal Report viewer is container of Crystal Report, in which you can open your report(*.rpt). Following is sample code for Crystal Report... /* Init. Crystal Report object*/ CrystalReport1 rptReport = new CrystalReport1(); /* Declaration and assignment of datatable as report source for report object*/ DataTable dtTemp = new DataTable(); rptReport.SetDataSource(dtTemp); /*Init. of report file to Reportviewer to view report*/ crystalReportViewer1.ReportSource = rptReport; This will work with Crystal Report. Data report is also there but Crystal report is more professional in compare to Data report

Code To create event handler at run time on button click in asp.net using c#

Code To create event handler at run time on button click in asp.net using c# using System; using System.Configuration; using System.Data; 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; public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { Button btn2 = new Button(); form1.Controls.Add(btn2); btn2.Text = "Example1"; btn2.Click += new EventHandler(btn2_Click); } void btn2_Click(object sender, EventArgs e) { Response.Write("Gooooooogle"); } }

ITIL,itil foundation version 3 certification

ITIL,itil foundation version 3 certification Any service oriented company can practice ITIL, to manage Infrastructure, Development and Operations. within this category youl find a lot of indian companies are practicing ITIL. The Lifecycle modules limit itself to the lifecycle stages and their dependencies - and will make sense for someone on the way to EXPERT certification. The Capability stream on the other hand is targeted at Practitioners and goes more into detail of the processes and their implementation. The Capability exams would hold more value owing to the depth, breadth and coverage of the subject area but I would expect the Capability exams to be tougher. For someone working in SW Development, the RCV (Release Control and Validation) capability module would probably hold most value followed by PPO (Planning, Protection and Optimization). http://ithelpline.com/files/docs/ITILQualS.pdf ITIL Process Based Approach http://www.securityfocus.com/ Dfiierence between IT...

Some Important keywords for education,blogging,adsense,traffic category for bloggers

Some Important keywords for education category for blogger computer education,computer fundamental,computer programming and tutorials,code help,property,sql server management studio,sql,query,pl sql, .NET ,.NET 3.5 Interview Questions ,.Net Interview ,UM Interview questions ,  3BHK starting ,asp.net tutorial ,A Letter To Bill Gates its funny   ,blog ,Blogging ,asp.net forums, ado.net How To Make Extra Money Online Earn money while working at home , Aankhen Khuli Ho, c programming tutorial, Acting Schools ,admission news ,Admission Notifications , advantages of asp with c over asp with vb.net , Ahmedabad property , AJAX  album ,mesothelioma symptoms,peritoneal mesothelioma,trans union,lung cancer,home equity loans , album review  All songs notation and chords at one place , allah , Analogies , Application Domain , Architecture Interview Question Java Interview Question , Article, Artificial   Neural Networks , Asp.Net  ASP.NET 2.0 Interview Ques...

SQL Tips-Search string in stored procedures of SQL,Sending Email

You can write following way to Search string in stored procedures of SQL. Syscomments and sysobject are sql system table. Sysobject table stored all object of sql like stored procedure,table name etc. declare @SearchStr      varchar(100) set @searchstr = 'String to search for' SELECT DISTINCT USER_NAME(o.uid) + '.' + OBJECT_NAME(c.id) AS 'Object name' FROM  syscomments c       INNER JOIN       sysobjects o       ON c.id = o.id WHERE c.text LIKE '%' + @SearchStr + '%'  and       encrypted = 0 I hope you will able to understand this SP. Sending mail through SQL Stored proceduare You can write following sql script in stored procedure to Send mail through SQL Stored procedure. @SenderNm varchar(100), @Senderemail varchar(100), @RecipientNm varchar(100), @Recipientemail varchar(100), @Subject varchar(200), @Body varchar(8000)...

Copy and paste the data entered into a master data worksheet in a different workbook

Copy and paste the data entered into a master data worksheet in a different workbook Sub CopyDataMacro() Workbooks.Open "D:\test\MasterData.xlsx" ThisWorkbook.Sheets("test1").Range(A11:K20").Copy Workbooks("MasterData.xlsx").Sheets( "test1").Cells(Rows.Count, 3).End(xlUp).Offset(1, 0).PasteSpecial Paste:=xlPasteValues ThisWorkbook.Sheets("test1").Range(C5").Copy Workbooks("MasterData.xlsx").Sheets( "test1").Cells(Rows.Count, 1).End(xlUp).Offset(1, 0).PasteSpecial Paste:=xlPasteValues ThisWorkbook.Sheets("test1").Range(C6").Copy Workbooks("MasterData.xlsx").Sheets( "test1").Cells(Rows.Count, 2).End(xlUp).Offset(1, 0).PasteSpecial Paste:=xlPasteValues Workbooks("MasterData.xlsx").Save Workbooks("MasterData.xlsx").Close End Sub

Text to columns through code in excel

All the data are combined in one column. Each cell has multiple values  to separate into the neighboring columns, which are separated by commas. Sub BreakDownTextToColumns() Dim strTextData As String Dim i As Integer, x As Integer Dim strSplitText$() x = 1 Range("A1").Select ' cell above data to separate Do Until ActiveCell.Offset(x, 0).Range("A1").Value = "" strTextData = ActiveCell.Offset(x, 0).Range("A1").Value strSplitText = Split(strTextData, ",") ' a comma is used as the signal to separate For i = 0 To UBound(strSplitText) ActiveCell.Offset(x, i).Range("A1").Value = (strSplitText(i)) Next i x = x + 1 Loop End Sub