Blog Home  Home Feed your aggregator (RSS 2.0)  
Software Code Help - Monday, June 22, 2009
Blog
 
# Monday, June 22, 2009
      Microsoft .net framework provide a facility for sending mail using System.Web.Mail(SMTP)
      First include this using System.Web.Mail in your code, For sending mail we are creating a function sendMail,
      it is used for sending email. For correctly running
      this code, please find register two dll "cdonts.dll" and "cdosys.dll".
      These two dll is microsoft dll used for sending mail.
 
      public void sendMail()
        { 

            try 

            {  

                //Provides properties and methods for sending messages using the Collaboration Data Objects for 
                  Windows 2000 (CDOSYS) message component.
                SmtpMail.SmtpServer= "SMTP Server IP Address";                 MailMessage msg = new MailMessage();                 // Specify the e-mail sender.                 msg.From = "rajshekhar@mail.com";//Self mail address // Set destinations for the e-mail message.                 msg.To = "Send Email Address";                 // Set destinations of Carbon Copy(CC) for the e-mail message.                 msg.Cc = "CC Email Address;                 // Set destinations of Blind carbon copies(BCC) for the e-mail message.                 msg.Bcc = "BCC Email Address";                 // Specify the message subject.                 msg.Subject = this.txtSubject.Text;                 // Specify the message content.                 msg.Body = "Content of Message Assign Here";                 msg.BodyFormat = MailFormat.Text;                 //The username for authenticating to an SMTP server using basic (clear-text) authentication.                 msg.Fields.Add( "http://schemas.microsoft.com/cdo/configuration/sendusername",
                                 "itq@vmaildeliver.vsnl.com");
                //The password used to authenticate to an SMTP server using basic (clear-text) authentication.                 msg.Fields.Add( "http://schemas.microsoft.com/cdo/configuration/sendpassword","itq.1.123");                 /%                         Specifies the authentication mechanism to use when authentication is required to send messages
                to an SMTP service using a TCP/IP network socket.                                                          The Secound parameter in smtpauthenticateis CdoProtocolsAuthentication enumeration, It is
                used to specify the mechanism used when authenticating to a Simple Mail Transfer Protocol(SMTP)
                service over the network.                 It has three different type of value:                 Name            Value                Description                 ====            =====                ============                 cdoAnonymous     0                 Do not authenticate.                                  cdoBasic         1                 Use basic (clear-text) authentication. The configuration
                                                   sendusername/sendpassword or postusername/postpassword fields
                                                  are used to specify credentials.                                  cdoNTLM             2              Use NTLM authentication (Secure Password Authentication in
                                                   Microsoft® Outlook® Express).The current process security
                                                   context is used to authenticate with the service.                                  */                                             msg.Fields.Add( "http://schemas.microsoft.com/cdo/configuration/smtpauthenticate",1);                 //Sending Message                             SmtpMail.Send(msg);                              }             catch (Exception ex)             {                 ErrorMessage("Send Mail Process was failed!!!");                              }             finally             {                                  SuccessMessage("Send Mail Process was successfull!!!");             }         }

You can use this above code for sending mail using SMTP in ASP.NET.

Monday, June 22, 2009 11:26:30 AM (GMT Daylight Time, UTC+01:00)  #    Comments [0]   .Net | asp.net  | 
# Sunday, June 21, 2009

In SQL Server 2000,


sp_lock is used to find dead lock inside the database.
if any dead lock occur then using "Kill spid" is to remove the dead lock.

Sunday, June 21, 2009 11:39:11 AM (GMT Daylight Time, UTC+01:00)  #    Comments [0]   SQL Server  | 
private void Page_Load(object sender, System.EventArgs e)
        {
            DataSet objds        = null;
            OleDbConnection conn = null;
            try
            {            
                if (File.Exists(Server.MapPath("UploadedFare/UploadedFare.xls").Trim()))
                {
                    gblConnSting = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + Server.MapPath
                     ("UploadedFare/UploadedFare.xls").Trim() + ";Extended Properties=\"Excel 8.0;HDR=YES;\"";                     conn    = new OleDbConnection(gblConnSting);;                                                          conn.Open();                     objds = new DataSet();                     OleDbDataAdapter objAdp    = new OleDbDataAdapter("select * from [Sheet1$] where
                                                                     [Airline] <> '' OR [Airline] <> null"
,conn);                     objAdp.AcceptChangesDuringFill = false;                     objAdp.Fill(objds);                             dgExcelData.DataSource    = objds.Tables[0].DefaultView;                     dgExcelData.DataBind();                 }                 else                     Response.Write("<B>No Fare Is Uploaded !</B>");             }             catch(Exception ex)             {                 new clsErrorLogging(ex);             }                     finally             {                 dgExcelData.Dispose();                 objds.Dispose();                 conn.Dispose();             }         }
 
Datagrid

       <asp:datagrid id="dgExcelData" runat="server" HeaderStyle-Wrap="False" BorderColor="LightGray"
        BorderWidth="1px">
        <ItemStyle Font-Size="X-Small" Wrap="False"></ItemStyle>
        <HeaderStyle Font-Size="Smaller" Font-Names="Verdana" Font-Bold="True" Wrap="False" HorizontalAlign="Center"
         ForeColor="Black" VerticalAlign="Middle" CssClass="tableheadergrey2" BackColor="Gainsboro" ></HeaderStyle>
       </asp:datagrid>
Sunday, June 21, 2009 11:37:58 AM (GMT Daylight Time, UTC+01:00)  #    Comments [0]   asp.net | C#  | 

HTTP Channel
The HTTP channel transports messages to and from remote objects using the SOAP protocol. All messages are passed through the SOAP formatter, where the message is changed into XML and serialized, and the required SOAP headers are added to the stream. It is also possible to configure the HTTP Channel to use the binary formatter. The resulting data stream is then transported to the target URI using the HTTP protocol.


TCP Channel
The TCP channel uses a binary formatter to serialize all messages to a binary stream and transport the stream to the target URI using the TCP protocol. It is also possible to configure the TCP channel to the SOAP formatter.

Sunday, June 21, 2009 11:33:06 AM (GMT Daylight Time, UTC+01:00)  #    Comments [0]   General  | 

Threading enables your C# program to perform concurrent processing so you can do more than one operation at a time.
C# supports parallel execution of code through multithreading.Threads are relatively
lightweight processes responsible for multitasking within a single
application.Thread is an independent execution path, able to run simultaneously
with other threads.
For implementing Threading, you first include System.Threading namespace in your project.

class ThreadClass
{
    static void Main() {
    Thread thread1 = new Thread (Display("1");
    Thread thread2 = new Thread (Display("2"));
    thread1.Start();
    thread2.Start();      // Run on the new thread
   
  }

    static void Diaplay(string strparameter)
    {
        while (true) Console.Write(strparameter);   // Write forever
    }
}

In the above program, two thread simultaneously running.
We can share a data between multiple thread through static variable.

class ThreadClass {
  static void Main() {
 static int num;
    Thread thread1 = new Thread (Display("Thread 1");
    Thread thread2 = new Thread (Display("Thread 2"));
    thread1.Start(); 
    thread2.Start();      // Run on the new thread
    
  }
 
  static void Diaplay(string strparameter) {
    while (true) 
    {
  num ++;
  Console.Write (num.ToString() + " " + strparameter);   // Write forever
 }
  }
}

In the above program, we are declaring a num static variable and this number is incrementing
by both thread.

Joining Threads:-Joining is used for blocks the calling thread until a thread terminates. Means
thread to stop processing and wait until a second thread completes its work,
----------
Once a thread starts running and in some situation if we need to tell the thread to stop processing and wait until a second thread completes processing, we need to join the first thread to the second thread. Use the following for the same. This will join the second thread to the first one.
---------

Sleep Threads:- you want to suspend your thread for a short time. For this  Thread
class provide a public static method "Sleep". Sleep is an overloaded function.

Thread.Sleep (Int32):  Suspends the current thread for a specified time.
e.g. thread1.Sleep(1000) //Sleep for 1000 millisecond
 Thread.Sleep (0); // give up CPU time-slice
Thread.Sleep (TimeSpan):  Blocks the current thread for a specified time. 
e.g. Thread.Sleep (TimeSpan.FromSeconds (5));
Thread.Sleep (TimeSpan.FromHours (1)); // sleep for 1 hour
Thread.Sleep (Timeout.Infinite); // sleep until interrupted

Killing Threads: Thread kill itself after completing its task, but you want to kill thread
before completing its task. For this you can use Abort() function.
e.g. thread1.Abort();
-----------
Threads has to die after the execution of the process in normal situations, occasionally it is required for the programmer to kill a thread. Threads can be killed using the following:
-----------
Suspend Thread: You want to stop executing your thread then you use Suspend() method and for running the suspending thread
You use Resume() method.

Thread Priority: Thread priority is basically used for giving which thread is high priority or
low priority. There are five level of priority
*Highest
*AboveNormal
*Normal
*BelowNormal
*Lowest

e.g.
 thread1.Priority = ThreadPriority.BelowNormal;
 thread2.Priority = ThreadPriority.Highest;
 
 Thread.ThreadState Property: ThreadState property gives the current state of thread status.
The initial value is Unstarted.
 ThreadState.Aborted
 ThreadState.AbortRequested
 ThreadState.Stopped
 ThreadState.Unstarted
 ThreadState.WaitSleepJoin;
 ThreadState.Background;
 ThreadState.SuspendRequested;
 ThreadState.Suspended
All of the above property return true or false on the basis of its status.
if you want to check abort status of thread1 then
  if ( thread1.ThreadState == ThreadState.Suspended}
 {
  thread1.Resume();//to again start the thread
 }
Rsume method is used for running the suspended thread. if the thread is not suspended then there will be no effect on thread status.

LOCK
====
"Change Style(Copied)
 lock marks a critical section of the code, and provides synchronization to an object.

Example:

public void Incrementer( )
{
  try
  {
    while (counter < 1000)
    {
      lock (this)
      {
        int temp = counter;
        temp ++;
        Thread.Sleep(1);
        counter = temp;
      }
      // assign the decremented value
      // and display the results
      Console.WriteLine("Thread {0}. Incrementer: {1}", 
         Thread.CurrentThread.Name, counter);
    }
  }

Sunday, June 21, 2009 11:30:18 AM (GMT Daylight Time, UTC+01:00)  #    Comments [0]   C#  | 

we can attach javascript in code behind using this style

 

private void Page_Load(object sender, System.EventArgs e)

{

System.Text.StringBuilder StrValidation = new System.Text.StringBuilder();

//Appending javascript in this string builder

StrValidation.AppendFormat("{0}",@"<script language='javascript'>

function validateForm()

{

if (isBlank(document.baseForm.txtEmail.value)) {

alert('Email ID can not be blank1 !');

document.baseForm.txtEmail.focus();

return false;

}

if (isBlank(document.baseForm.txtSubject.value)) {

alert('Subject can not be blank !');

document.baseForm.txtSubject.focus();

return false;

}

if (isBlank(document.baseForm.txtMessage.value)) {

alert('Please Enter Message in Message Box !');

document.baseForm.txtMessage.focus();

return false;

}

return true;

} </script>");

Page.RegisterClientScriptBlock("AddValidation",StrValidation.ToString());

this.ibtnSubmit.Attributes.Add("onClick", "return validateForm();");

Sunday, June 21, 2009 11:21:26 AM (GMT Daylight Time, UTC+01:00)  #    Comments [0]   asp.net  | 

private void Page_Load(object sender, System.EventArgs e)

{

      base.OuterTable.HorizontalAlign = HorizontalAlign.Center;

      base.ContentBar.VerticalAlign = VerticalAlign.Top;

}

Sunday, June 21, 2009 11:18:50 AM (GMT Daylight Time, UTC+01:00)  #    Comments [0]   asp.net  | 

Everyone who writes code

Describe the difference between a Thread and a Process?
What is a Windows Service and how does its lifecycle differ from a "standard" EXE?
What is the maximum amount of memory any single process on Windows can address? Is this different than the maximum virtual memory for the system? How would this affect a system design?
What is the difference between an EXE and a DLL?
What is strong-typing versus weak-typing? Which is preferred? Why?
Corillian's product is a "Component Container." Name at least 3 component containers that ship now with the Windows Server Family.
What is a PID? How is it useful when troubleshooting a system?
How many processes can listen on a single TCP/IP port?
What is the GAC? What problem does it solve?
Mid-Level .NET Developer

Describe the difference between Interface-oriented, Object-oriented and Aspect-oriented programming.
Describe what an Interface is and how it’s different from a Class.
What is Reflection?
What is the difference between XML Web Services using ASMX and .NET Remoting using SOAP?
Are the type system represented by XmlSchema and the CLS isomorphic?
Conceptually, what is the difference between early-binding and late-binding?
Is using Assembly.Load a static reference or dynamic reference?
When would using Assembly.LoadFrom or Assembly.LoadFile be appropriate?
What is an Asssembly Qualified Name? Is it a filename? How is it different?
Is this valid? Assembly.Load("foo.dll");
How is a strongly-named assembly different from one that isn’t strongly-named?
Can DateTimes be null?
What is the JIT? What is NGEN? What are limitations and benefits of each?
How does the generational garbage collector in the .NET CLR manage object lifetime? What is non-deterministic finalization?
What is the difference between Finalize() and Dispose()?
How is the using() pattern useful? What is IDisposable? How does it support deterministic finalization?
What does this useful command line do? tasklist /m "mscor*"
What is the difference between in-proc and out-of-proc?
What technology enables out-of-proc communication in .NET?
When you’re running a component within ASP.NET, what process is it running within on Windows XP? Windows 2000? Windows 2003?
Senior Developers/Architects

What’s wrong with a line like this? DateTime.Parse(myString);
What are PDBs? Where must they be located for debugging to work?
What is cyclomatic complexity and why is it important?
Write a standard lock() plus “double check” to create a critical section around a variable access.
What is FullTrust? Do GAC’ed assemblies have FullTrust?
What benefit does your code receive if you decorate it with attributes demanding specific Security permissions?
What does this do? gacutil /l | find /i "Corillian"
What does this do? sn -t foo.dll
What ports must be open for DCOM over a firewall? What is the purpose of Port 135?
Contrast OOP and SOA. What are tenets of each?
How does the XmlSerializer work? What ACL permissions does a process using it require?
Why is catch(Exception) almost always a bad idea?
What is the difference between Debug.Write and Trace.Write? When should each be used?
What is the difference between a Debug and Release build? Is there a significant speed difference? Why or why not?
Does JITting occur per-assembly or per-method? How does this affect the working set?
Contrast the use of an abstract base class against an interface?
What is the difference between a.Equals(b) and a == b?
In the context of a comparison, what is object identity versus object equivalence?
How would one do a deep copy in .NET?
Explain current thinking around IClonable.
What is boxing?
Is string a value type or a reference type?
What is the significance of the "PropertySpecified" pattern used by the XmlSerializer? What problem does it attempt to solve?
Why are out parameters a bad idea in .NET? Are they?
Can attributes be placed on specific parameters to a method? Why is this useful?
C# Component Developers

Juxtapose the use of override with new. What is shadowing?
Explain the use of virtual, sealed, override, and abstract.
Explain the importance and use of each component of this string: Foo.Bar, Version=2.0.205.0, Culture=neutral, PublicKeyToken=593777ae2d274679d
Explain the differences between public, protected, private and internal.
What benefit do you get from using a Primary Interop Assembly (PIA)?
By what mechanism does NUnit know what methods to test?
What is the difference between: catch(Exception e){throw e;} and catch(Exception e){throw;}
What is the difference between typeof(foo) and myFoo.GetType()?
Explain what’s happening in the first constructor: public class c{ public c(string a) : this() {;}; public c() {;} } How is this construct useful?
What is this? Can this be used within a static method?
ASP.NET (UI) Developers

Describe how a browser-based Form POST becomes a Server-Side event like Button1_OnClick.
What is a PostBack?
What is ViewState? How is it encoded? Is it encrypted? Who uses ViewState?
What is the <machinekey> element and what two ASP.NET technologies is it used for?
What three Session State providers are available in ASP.NET 1.1? What are the pros and cons of each?
What is Web Gardening? How would using it affect a design?
Given one ASP.NET application, how many application objects does it have on a single proc box? A dual? A dual with Web Gardening enabled? How would this affect a design?
Are threads reused in ASP.NET between reqeusts? Does every HttpRequest get its own thread? Should you use Thread Local storage with ASP.NET?
Is the [ThreadStatic] attribute useful in ASP.NET? Are there side effects? Good or bad?
Give an example of how using an HttpHandler could simplify an existing design that serves Check Images from an .aspx page.
What kinds of events can an HttpModule subscribe to? What influence can they have on an implementation? What can be done without recompiling the ASP.NET Application?
Describe ways to present an arbitrary endpoint (URL) and route requests to that endpoint to ASP.NET.
Explain how cookies work. Give an example of Cookie abuse.
Explain the importance of HttpRequest.ValidateInput()?
What kind of data is passed via HTTP Headers?
Juxtapose the HTTP verbs GET and POST. What is HEAD?
Name and describe at least a half dozen HTTP Status Codes and what they express to the requesting client.
How does if-not-modified-since work? How can it be programmatically implemented with ASP.NET?
Explain <@OutputCache%> and the usage of VaryByParam, VaryByHeader.
How does VaryByCustom work?
How would one implement ASP.NET HTML output caching, caching outgoing versions of pages generated via all values of q= except where q=5 (as in http://localhost/page.aspx?q=5)?
Developers using XML

What is the purpose of XML Namespaces?
When is the DOM appropriate for use? When is it not? Are there size limitations?
What is the WS-I Basic Profile and why is it important?
Write a small XML document that uses a default namespace and a qualified (prefixed) namespace. Include elements from both namespace.
What is the one fundamental difference between Elements and Attributes?
What is the difference between Well-Formed XML and Valid XML?
How would you validate XML using .NET?
Why is this almost always a bad idea? When is it a good idea? myXmlDocument.SelectNodes("//mynode");
Describe the difference between pull-style parsers (XmlReader) and eventing-readers (Sax)
What is the difference between XPathDocument and XmlDocument? Describe situations where one should be used over the other.
What is the difference between an XML "Fragment" and an XML "Document."
What does it meant to say “the canonical” form of XML?
Why is the XML InfoSet specification different from the Xml DOM? What does the InfoSet attempt to solve?
Contrast DTDs versus XSDs. What are their similarities and differences? Which is preferred and why?
Does System.Xml support DTDs? How?
Can any XML Schema be represented as an object graph? Vice versa?

Sunday, June 21, 2009 11:16:13 AM (GMT Daylight Time, UTC+01:00)  #    Comments [0]   .Net  | 

tempdb is one of the key working areas for your server. Whenever you issue a complex or large query that SQL Server needs to build interim tables to solve, it does so in tempdb. Whenever you create a temporary table of your own, it is created in tempdb, even though you think you’re creating it in the current database. Whenever there is a need for data to be stored temporarily, it’s probably stored in tempdb.

Sunday, June 21, 2009 11:14:49 AM (GMT Daylight Time, UTC+01:00)  #    Comments [0]   SQL Server  | 

A subreport is a report within a report
In Crystal Reports, there are two types of subreports — unlinked and linked.

The Unlinked Subreport
Unlinked subreports do not attempt to coordinate their data with the primary report. In other words, an unlinked subreport does not match up records to the records within a primary report. Unlinked subreports do not need to use the same data as the primary report — in fact, an unlinked subreport often does not even share the same data source as the primary report.

The Linked Subreport
Linked subreports, in comparison to unlinked subreports, do share the same data source as a primary report. A linked subreport's data is linked and coordinated with the primary report's data. In other words, both reports contain records that are matched up.

As an example, say that your primary report contains employee information and your subreport contains order information (where this order information is linked to the employee information). For each employee record, a linked subreport would include all orders for that employee only. You can try your hand at creating a linked subreport later in this chapter.

 

Sunday, June 21, 2009 11:08:55 AM (GMT Daylight Time, UTC+01:00)  #    Comments [0]   Crystal Report  | 
Copyright © 2010 SoftwareCodeHelp. All rights reserved.
DasBlog 'Portal' theme by Johnny Hughes.
Pick a theme: