put this function in javascript-----
function capLock(e){
kc = e.keyCode?e.keyCode:e.which;
sk = e.shiftKey?e.shiftKey:((kc == 16)?true:false);
if((kc >= 65 && kc <= 90)||((kc >= 97 && kc <= 122) && sk))
document.getElementById('divMayus').style.visibility = 'visible';
else
document.getElementById('divMayus').style.visibility = 'hidden';
}
place these lines in form tag.--------
asp:textbox id="txt_pwd" onkeypress="capLock(event)" runat="server" style="color: black;width: 110px;text-align: left;height: 20px;" TextMode="Password" MaxLength="7"/asp:textbox
div id="divMayus" style="visibility:hidden;color:Red;height:10px;width:100px;background-color:#ffffcc;"Caps Lock is on./div
Tuesday, April 28, 2009
Monday, April 20, 2009
Service Oriented Architecture(SOA)
Abbreviated SOA, an application architecture in which all functions, or services, are defined using a description language and have invokable interfaces that are called to perform business processes. Each interaction is independent of each and every other interaction and the interconnect protocols of the communicating devices (i.e., the infrastructure components that determine the communication system do not affect the interfaces). Because interfaces are platform-independent, a client from any device using any operating system in any language can use the service.
Though built on similar principles, SOA is not the same as Web services, which indicates a collection of technologies, such as SOAP and XML. SOA is more than a set of technologies and runs independent of any specific technologies.
Though built on similar principles, SOA is not the same as Web services, which indicates a collection of technologies, such as SOAP and XML. SOA is more than a set of technologies and runs independent of any specific technologies.
About web services wcf,wpf,wwf,wcs
1. WPF (Windows Presentation Foundation).
2. WCF (Windows Communication Foundation)
3. WF (Windows Workflow
Foundation)
4. WCS (Windows Card Space)
1. WPF (Windows Presentation Foundation)
New era for Windows Desktop Application UI designing. Following are some of the main features
• Now onwards there are no WinForm Controls that we are using till .net 2.0. Everything is XML. Whatever you write will be the XML for the desigining. Officially Microsoft gives its name XAML
• Because of this XML everything you can do in Html pages will now possible in Winform design also
• Cascading Style like web is possible in Winform also
• Designer draw the screen in Photoshop just like they where doing for web page. And then you can do the same step as you were doing to convert that layout in html
• Provides new type of application known as "WPF Browser based application", which can run in Internet Explorer just like the ActiveX and Applets are running
• 3D modeling.
• Animation like GIF file can be possible for the windows form.
Links
WPF Architecures and functionality
http://msdn.microsoft.com/library/en-us/dnlong/html/wpf101.asp
WPF for beginners
http://wpf.netfx3.com/
Find the features in detail for WPF
http://en.wikipedia.org/wiki/Windows_Presentation_Foundation
Introduction Videos
http://msdn.microsoft.com/msdntv/episode.aspx?xml=episodes/en/20060817wpfkg/manifest.xml
First Hands on lab
http://www.microsoft.com/downloads/details.aspx?FamilyID=05755a9d-98fa-4f16-bfdc-023e3fd34763&DisplayLang=en
2. WCF (Windows Communication Foundation)
New era for Communication methods for the Distributed application development
and Grid Computing with much flexibility that we never have before. This is something they are calling Service Oriented Application Architecture.
• Web service, WSE, Remorting, MSMQ... all of this is now a mapped in single API
• Easy to deploy and integration with Application.
• XML web service access speed will no more issue with the help of WCF.
Links
Learning WCF (Architecture and Foundation)
http://msdn.microsoft.com/library/en-us/dnlong/html/wcfarch.asp
Introduction of Developing WCF
http://msdn.microsoft.com/library/en-us/dnlong/html/introtowcf.asp
3. WF (Windows Workflow Foundation)
This is really really very cool features that Microsoft comes up with .net 3.0. With the help of this foundation you can implement any complex Business logic which you could not even think for it. Just within a few hours you can implement few weeks of work. The features are
• Draw the Flow chart and the coding part will be written automatically. Of course you have to feed some line of code
• Represent your logic on document which is actually the code you implement
• No more syntax and commenting for Code, because your logic is in form of Flow charts
• Maintain the State of Object (Application Objects) with the Help of State Chart. Draw the state diagram for your Object and it will reach exactly in the state as per you have drawn with in IDE
• I could not believe on my eyes when I saw the demonstration of Parallel Computing and Multi threading application development. Just to draw the flow chart with some parallel Flow in sequence, that’s all to do. Not to think anything for the thread and multi process management
Links
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnlong/html/hmnwkfwwf.asp
Understanding Components in WF
http://msdn.microsoft.com/msdnmag/issues/06/12/windowsworkflow/
4. WCS (Windows Card Space)
It is formerly known as the code named "InfoCard" that helps to protect user’s digital identities against spoofing, phishing and tampering. It enables end users to provide digital identity to online services in a simple and trusted way.
Here is how it works…
Instead of authenticating users with passwords, websites authenticate users with security tokens. Submit identity token to the website with just a few clicks of a mouse. The website accepts this token presented by the user, decrypts the token, validates this credential and uses this information internally to identify the user. Cryptographic techniques along with responsible protocols are used for identification of the user. CardSpace includes a self-issued identity provider, which runs on the local Windows system and it can produce information cards just like any other identity provider.
Users download cards from identity providers such as their bank, employer, government agency, membership organization, or create their own self-issued cards. When a Website or Web service requests a user’s credentials, CardSpace will be invoked and allow the user to select a card to present. CardSpace then retrieves a verifiable credential from the selected identity provider, or the self-issuing authority as the case may be, utilizing interoperable protocols. It then forwards the credential to the target application. This provides users with a simple, secure and familiar sign-on experience that is consistent across all Websites and Web services.
We can enjoy the technology, simplicity, consistency and mainly security that Card Space gifts us.
2. WCF (Windows Communication Foundation)
3. WF (Windows Workflow
Foundation)
4. WCS (Windows Card Space)
1. WPF (Windows Presentation Foundation)
New era for Windows Desktop Application UI designing. Following are some of the main features
• Now onwards there are no WinForm Controls that we are using till .net 2.0. Everything is XML. Whatever you write will be the XML for the desigining. Officially Microsoft gives its name XAML
• Because of this XML everything you can do in Html pages will now possible in Winform design also
• Cascading Style like web is possible in Winform also
• Designer draw the screen in Photoshop just like they where doing for web page. And then you can do the same step as you were doing to convert that layout in html
• Provides new type of application known as "WPF Browser based application", which can run in Internet Explorer just like the ActiveX and Applets are running
• 3D modeling.
• Animation like GIF file can be possible for the windows form.
Links
WPF Architecures and functionality
http://msdn.microsoft.com/library/en-us/dnlong/html/wpf101.asp
WPF for beginners
http://wpf.netfx3.com/
Find the features in detail for WPF
http://en.wikipedia.org/wiki/Windows_Presentation_Foundation
Introduction Videos
http://msdn.microsoft.com/msdntv/episode.aspx?xml=episodes/en/20060817wpfkg/manifest.xml
First Hands on lab
http://www.microsoft.com/downloads/details.aspx?FamilyID=05755a9d-98fa-4f16-bfdc-023e3fd34763&DisplayLang=en
2. WCF (Windows Communication Foundation)
New era for Communication methods for the Distributed application development
and Grid Computing with much flexibility that we never have before. This is something they are calling Service Oriented Application Architecture.
• Web service, WSE, Remorting, MSMQ... all of this is now a mapped in single API
• Easy to deploy and integration with Application.
• XML web service access speed will no more issue with the help of WCF.
Links
Learning WCF (Architecture and Foundation)
http://msdn.microsoft.com/library/en-us/dnlong/html/wcfarch.asp
Introduction of Developing WCF
http://msdn.microsoft.com/library/en-us/dnlong/html/introtowcf.asp
3. WF (Windows Workflow Foundation)
This is really really very cool features that Microsoft comes up with .net 3.0. With the help of this foundation you can implement any complex Business logic which you could not even think for it. Just within a few hours you can implement few weeks of work. The features are
• Draw the Flow chart and the coding part will be written automatically. Of course you have to feed some line of code
• Represent your logic on document which is actually the code you implement
• No more syntax and commenting for Code, because your logic is in form of Flow charts
• Maintain the State of Object (Application Objects) with the Help of State Chart. Draw the state diagram for your Object and it will reach exactly in the state as per you have drawn with in IDE
• I could not believe on my eyes when I saw the demonstration of Parallel Computing and Multi threading application development. Just to draw the flow chart with some parallel Flow in sequence, that’s all to do. Not to think anything for the thread and multi process management
Links
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnlong/html/hmnwkfwwf.asp
Understanding Components in WF
http://msdn.microsoft.com/msdnmag/issues/06/12/windowsworkflow/
4. WCS (Windows Card Space)
It is formerly known as the code named "InfoCard" that helps to protect user’s digital identities against spoofing, phishing and tampering. It enables end users to provide digital identity to online services in a simple and trusted way.
Here is how it works…
Instead of authenticating users with passwords, websites authenticate users with security tokens. Submit identity token to the website with just a few clicks of a mouse. The website accepts this token presented by the user, decrypts the token, validates this credential and uses this information internally to identify the user. Cryptographic techniques along with responsible protocols are used for identification of the user. CardSpace includes a self-issued identity provider, which runs on the local Windows system and it can produce information cards just like any other identity provider.
Users download cards from identity providers such as their bank, employer, government agency, membership organization, or create their own self-issued cards. When a Website or Web service requests a user’s credentials, CardSpace will be invoked and allow the user to select a card to present. CardSpace then retrieves a verifiable credential from the selected identity provider, or the self-issuing authority as the case may be, utilizing interoperable protocols. It then forwards the credential to the target application. This provides users with a simple, secure and familiar sign-on experience that is consistent across all Websites and Web services.
We can enjoy the technology, simplicity, consistency and mainly security that Card Space gifts us.
creating a xml file and reading it and inserting into database
Creating xml file
Step1: create a function as below
void crete_xml()
{
/// creation of table
DataTable dt = new DataTable();
DataColumn gis1 = new DataColumn("gisno");
DataColumn appname = new DataColumn("appname");
DataColumn fname = new DataColumn("fname");
DataColumn age = new DataColumn("age");
///creation of collumns
dt.Columns.Add(gis1);
dt.Columns.Add(appname);
dt.Columns.Add(fname);
dt.Columns.Add(age);
dt.Columns.Add(prof);
//creation of rows
DataRow dr = dt.NewRow();
dr["gisno"] = lbl_GISno.Text;
dr["appname"] = txt_name.Text;
dr["fname"] = txt_Father.Text;
dr["age"] = txt_Age.Text;
//creating & deleting xml file in the given path
dt.Rows.Add(dr);
DataSet df = new DataSet();
df.Tables.Add(dt);
File.Delete(MapPath("my.xml"));
df.WriteXml(MapPath("my.xml"));
}
----paste this function in page load---
Reading tht xml file in the next aspx page and inserting in to data base
----------create function--------
void read_xml()
{
ds.ReadXml(MapPath("my.xml"));
if (ds.Tables[0].Rows.Count > 0)
{
lbl_GISno.Text = ds.Tables[0].Rows[0]["gisno"].ToString();
lbl_name.Text = ds.Tables[0].Rows[0]["appname"].ToString();
lbl_fname.Text = ds.Tables[0].Rows[0]["fname"].ToString();
lbl_age.Text = ds.Tables[0].Rows[0]["age"].ToString();
}
paste the function in page load
///inserting in to database
void InsertQuery()
{
con.ConnectionString = strConnstring;
con.Open();
SqlCommand cmd = new SqlCommand("InsertFMS", con);
cmd.CommandType = CommandType.StoredProcedure;
SqlParameter pr1 = new SqlParameter("@app_id", SqlDbType.VarChar);
pr1.Value = lbl_GISno.Text;
cmd.Parameters.Add(pr1);
SqlParameter pr2 = new SqlParameter("@Name", SqlDbType.VarChar);
pr2.Value = lbl_name.Text;
cmd.Parameters.Add(pr2);
//
SqlParameter prm_Father = new SqlParameter("@Father", SqlDbType.VarChar);
prm_Father.Value = lbl_fname.Text;
cmd.Parameters.Add(prm_Father);
SqlParameter prm_Age = new SqlParameter("@Age", SqlDbType.VarChar);
prm_Age.Value = lbl_age.Text;
cmd.Parameters.Add(prm_Age);
}
paste the function in pageload
Step1: create a function as below
void crete_xml()
{
/// creation of table
DataTable dt = new DataTable();
DataColumn gis1 = new DataColumn("gisno");
DataColumn appname = new DataColumn("appname");
DataColumn fname = new DataColumn("fname");
DataColumn age = new DataColumn("age");
///creation of collumns
dt.Columns.Add(gis1);
dt.Columns.Add(appname);
dt.Columns.Add(fname);
dt.Columns.Add(age);
dt.Columns.Add(prof);
//creation of rows
DataRow dr = dt.NewRow();
dr["gisno"] = lbl_GISno.Text;
dr["appname"] = txt_name.Text;
dr["fname"] = txt_Father.Text;
dr["age"] = txt_Age.Text;
//creating & deleting xml file in the given path
dt.Rows.Add(dr);
DataSet df = new DataSet();
df.Tables.Add(dt);
File.Delete(MapPath("my.xml"));
df.WriteXml(MapPath("my.xml"));
}
----paste this function in page load---
Reading tht xml file in the next aspx page and inserting in to data base
----------create function--------
void read_xml()
{
ds.ReadXml(MapPath("my.xml"));
if (ds.Tables[0].Rows.Count > 0)
{
lbl_GISno.Text = ds.Tables[0].Rows[0]["gisno"].ToString();
lbl_name.Text = ds.Tables[0].Rows[0]["appname"].ToString();
lbl_fname.Text = ds.Tables[0].Rows[0]["fname"].ToString();
lbl_age.Text = ds.Tables[0].Rows[0]["age"].ToString();
}
paste the function in page load
///inserting in to database
void InsertQuery()
{
con.ConnectionString = strConnstring;
con.Open();
SqlCommand cmd = new SqlCommand("InsertFMS", con);
cmd.CommandType = CommandType.StoredProcedure;
SqlParameter pr1 = new SqlParameter("@app_id", SqlDbType.VarChar);
pr1.Value = lbl_GISno.Text;
cmd.Parameters.Add(pr1);
SqlParameter pr2 = new SqlParameter("@Name", SqlDbType.VarChar);
pr2.Value = lbl_name.Text;
cmd.Parameters.Add(pr2);
//
SqlParameter prm_Father = new SqlParameter("@Father", SqlDbType.VarChar);
prm_Father.Value = lbl_fname.Text;
cmd.Parameters.Add(prm_Father);
SqlParameter prm_Age = new SqlParameter("@Age", SqlDbType.VarChar);
prm_Age.Value = lbl_age.Text;
cmd.Parameters.Add(prm_Age);
}
paste the function in pageload
session state servers
Session in ASP.net can be stored in 3 ways.
1. Inproc
2. State Server
3. SqlServer
The InProc mode of Session State management is the fastest among all of the storage modes available and stores the Session data in the ASP.NET worker process.
Performance will be effected if the amount of data stored in the session is large. Basically the session is stored in the memory space of an application
domain and is volatile.So if asp.net worker process i.e. aspnet_wp.exe restarts then the session state will be lost.
The Session State here entirely depends on the lifetime of the application domain that it runs on. Note that the Session_End event which is fired internally by the web server is supported only in InProc mode. Note that even if the Session State is set to read only using the EnableSessionState attribute, in the InProc mode one can still modify the session. The Session_OnEnd event is invoked by the runtime environment when we make a call to the Session.Abandon() method or when the user's session times out. Further, any change made in the settings in the web.config file unloads the application domain and the Session State too.
The StateServer mode uses a stand-alone Microsoft Windows service that is independent of IIS and can run on a separate server.
In this case the session state is serialized and stored in memory in a separate process that is managed by the aspnet_state.exe file.
This has got some performance drawbacks due to the overhead involved in serialization and de-serialization of objects.
The main primary advantage of storing the Session State in a State Server is that it is not in the same process as the ASP.NET and a crash of ASP.NET
would in no way destroy the session data. Secondly, this mode of Session State storage enables to share the information across a web garden or a web farm.
Rememeber that this mode is slow compared to the InProc mode as it is stored in an external process.
The SQLServer mode of Session State management is a reliable, secure and centralized storage of a session state
In this the Session data is serialized and stored in a database table in the SQL Server database.
It can typically be used in the web farms.
It has performance bottlenecks as in the State Server mode of Session State management due to the overhead involved in serialization and de-serialization
of the objects that are stored and retrieved to and from the Session.
SQL Server is more secure than the InProc or the State server modes of Session State storages as the data can be secured easily by
configuring the SQL Server security.
Storage location
* InProc - session kept as live objects in web server (aspnet_wp.exe). Use "cookieless" configuration in web.config to "munge" the sessionId onto the URL (solves cookie/domain/path RFC problems too!)
* StateServer - session serialized and stored in memory in a separate process (aspnet_state.exe). State Server can run on another machine
* SQLServer - session serialized and stored in SQL server
Performance
* InProc - Fastest, but the more session data, the more memory is consumed on the web server, and that can affect performance.
* StateServer - When storing data of basic types (e.g. string, integer, etc), in one test environment it's 15% slower than InProc. However, the cost of serialization/deserialization can affect performance if you're storing lots
of objects. You have to do performance testing for your own scenario.
* SQLServer - When storing data of basic types (e.g. string, integer, etc), in one test environment it's 25% slower than InProc. Same warning about serialization as in StateServer.
Robustness
* InProc - Session state will be lost if the worker process (aspnet_wp.exe) recycles, or if the appdomain restarts. It's because session state is stored in the memory space of an appdomain. For details, see KB324772.
* StateServer - Solve the session state loss problem in InProc mode. Allows a webfarm to store session on a central server. Single point of failure at the State Server.
* SQLServer - Similar to StateServer. Moreover, session state data can survive a SQL server restart, and you can also take advantage of SQL server failover cluster, after you've followed instructions in KB 311029.
1. Inproc
2. State Server
3. SqlServer
The InProc mode of Session State management is the fastest among all of the storage modes available and stores the Session data in the ASP.NET worker process.
Performance will be effected if the amount of data stored in the session is large. Basically the session is stored in the memory space of an application
domain and is volatile.So if asp.net worker process i.e. aspnet_wp.exe restarts then the session state will be lost.
The Session State here entirely depends on the lifetime of the application domain that it runs on. Note that the Session_End event which is fired internally by the web server is supported only in InProc mode. Note that even if the Session State is set to read only using the EnableSessionState attribute, in the InProc mode one can still modify the session. The Session_OnEnd event is invoked by the runtime environment when we make a call to the Session.Abandon() method or when the user's session times out. Further, any change made in the settings in the web.config file unloads the application domain and the Session State too.
The StateServer mode uses a stand-alone Microsoft Windows service that is independent of IIS and can run on a separate server.
In this case the session state is serialized and stored in memory in a separate process that is managed by the aspnet_state.exe file.
This has got some performance drawbacks due to the overhead involved in serialization and de-serialization of objects.
The main primary advantage of storing the Session State in a State Server is that it is not in the same process as the ASP.NET and a crash of ASP.NET
would in no way destroy the session data. Secondly, this mode of Session State storage enables to share the information across a web garden or a web farm.
Rememeber that this mode is slow compared to the InProc mode as it is stored in an external process.
The SQLServer mode of Session State management is a reliable, secure and centralized storage of a session state
In this the Session data is serialized and stored in a database table in the SQL Server database.
It can typically be used in the web farms.
It has performance bottlenecks as in the State Server mode of Session State management due to the overhead involved in serialization and de-serialization
of the objects that are stored and retrieved to and from the Session.
SQL Server is more secure than the InProc or the State server modes of Session State storages as the data can be secured easily by
configuring the SQL Server security.
Storage location
* InProc - session kept as live objects in web server (aspnet_wp.exe). Use "cookieless" configuration in web.config to "munge" the sessionId onto the URL (solves cookie/domain/path RFC problems too!)
* StateServer - session serialized and stored in memory in a separate process (aspnet_state.exe). State Server can run on another machine
* SQLServer - session serialized and stored in SQL server
Performance
* InProc - Fastest, but the more session data, the more memory is consumed on the web server, and that can affect performance.
* StateServer - When storing data of basic types (e.g. string, integer, etc), in one test environment it's 15% slower than InProc. However, the cost of serialization/deserialization can affect performance if you're storing lots
of objects. You have to do performance testing for your own scenario.
* SQLServer - When storing data of basic types (e.g. string, integer, etc), in one test environment it's 25% slower than InProc. Same warning about serialization as in StateServer.
Robustness
* InProc - Session state will be lost if the worker process (aspnet_wp.exe) recycles, or if the appdomain restarts. It's because session state is stored in the memory space of an appdomain. For details, see KB324772.
* StateServer - Solve the session state loss problem in InProc mode. Allows a webfarm to store session on a central server. Single point of failure at the State Server.
* SQLServer - Similar to StateServer. Moreover, session state data can survive a SQL server restart, and you can also take advantage of SQL server failover cluster, after you've followed instructions in KB 311029.
Tuesday, April 14, 2009
Redirect to New window using Response.Redirect()
Hi,Iam presenting the code to redirect to a new page using our famous response.redirect
Just add this function to .cs file
public static class ResponseHelper
{
public static void Redirect(string url, string target, string windowFeatures)
{
HttpContext context = HttpContext.Current;
if ((String.IsNullOrEmpty(target) ||
target.Equals("_self", StringComparison.OrdinalIgnoreCase)) && String.IsNullOrEmpty(windowFeatures))
{
context.Response.Redirect(url);
}
else
{
Page page = (Page)context.Handler;
if (page == null)
{
throw new InvalidOperationException(
"Cannot redirect to new window outside Page context.");
}
url = page.ResolveClientUrl(url);
string script;
if (!String.IsNullOrEmpty(windowFeatures))
{
script = @"window.open(""{0}"", ""{1}"", ""{2}"");";
}
else
{
script = @"window.open(""{0}"", ""{1}"");";
}
script = String.Format(script, url, target, windowFeatures);
ScriptManager.RegisterStartupScript(page,
typeof(Page),
"Redirect",
script,
true);
}
}
}
now call the function on button click
ResponseHelper.Redirect("popup.aspx", "_blank", "menubar=0,width=100,height=100");
Just add this function to .cs file
public static class ResponseHelper
{
public static void Redirect(string url, string target, string windowFeatures)
{
HttpContext context = HttpContext.Current;
if ((String.IsNullOrEmpty(target) ||
target.Equals("_self", StringComparison.OrdinalIgnoreCase)) && String.IsNullOrEmpty(windowFeatures))
{
context.Response.Redirect(url);
}
else
{
Page page = (Page)context.Handler;
if (page == null)
{
throw new InvalidOperationException(
"Cannot redirect to new window outside Page context.");
}
url = page.ResolveClientUrl(url);
string script;
if (!String.IsNullOrEmpty(windowFeatures))
{
script = @"window.open(""{0}"", ""{1}"", ""{2}"");";
}
else
{
script = @"window.open(""{0}"", ""{1}"");";
}
script = String.Format(script, url, target, windowFeatures);
ScriptManager.RegisterStartupScript(page,
typeof(Page),
"Redirect",
script,
true);
}
}
}
now call the function on button click
ResponseHelper.Redirect("popup.aspx", "_blank", "menubar=0,width=100,height=100");
Saturday, April 11, 2009
sending automatic mail and attachments using c#.net
SmtpClient obj = new SmtpClient("smtp.gmail.com",587);
//587 is the port number supplied by gmail team. we can use 456 also
obj.EnableSsl = true;
obj.Credentials=new System.Net.NetworkCredential("username@gmail.com", "password");
MailMessage Mailmsg = new MailMessage();
Mailmsg.To.Clear();
Mailmsg.From = new MailAddress("username@gmail.com");
Mailmsg.Subject = "Subject";
Mailmsg.Body ="Body";
//adding attachments
Attachment at = new Attachment(Server.MapPath("~/style.css"));
Mailmsg.Attachments.Add(at);
Mailmsg.Priority = MailPriority.High;
Mailmsg.IsBodyHtml = true;
Mailmsg.To.Add(new MailAddress("mailaddress", "name"));
Mailmsg.BodyEncoding = System.Text.Encoding.Default;
try
{
obj.Send(Mailmsg);
}
catch (Exception ex)
{
Response.Write(ex.Message.ToString());
}
-------------------example how to use above code--------------
SmtpClient obj = new SmtpClient("smtp.gmail.com", 587);
//587 is the port number supplied by gmail team. we can use 456 also
obj.EnableSsl = true;
obj.Credentials = new System.Net.NetworkCredential("admg.fms@gmail.com","quantum123");
MailMessage Mailmsg = new MailMessage();
Mailmsg.To.Clear();
Mailmsg.From = new MailAddress("admg.fms@gmail.com");
Mailmsg.Subject = "Application rejected";
Mailmsg.Body = "Body";
//adding attachments
Attachment at = new Attachment(Server.MapPath("~/photo.jpg"));
Mailmsg.Attachments.Add(at);
Mailmsg.Priority = MailPriority.High;
Mailmsg.IsBodyHtml = true;
Mailmsg.To.Add(new MailAddress("kishoreswrn@gmail.com", "kishore"));
Mailmsg.BodyEncoding = System.Text.Encoding.Default;
try
{
obj.Send(Mailmsg);
}
catch (Exception ex)
{
Response.Write(ex.Message.ToString());
}
Response.Write("Mail Sent Successfully");
}
//587 is the port number supplied by gmail team. we can use 456 also
obj.EnableSsl = true;
obj.Credentials=new System.Net.NetworkCredential("username@gmail.com", "password");
MailMessage Mailmsg = new MailMessage();
Mailmsg.To.Clear();
Mailmsg.From = new MailAddress("username@gmail.com");
Mailmsg.Subject = "Subject";
Mailmsg.Body ="Body";
//adding attachments
Attachment at = new Attachment(Server.MapPath("~/style.css"));
Mailmsg.Attachments.Add(at);
Mailmsg.Priority = MailPriority.High;
Mailmsg.IsBodyHtml = true;
Mailmsg.To.Add(new MailAddress("mailaddress", "name"));
Mailmsg.BodyEncoding = System.Text.Encoding.Default;
try
{
obj.Send(Mailmsg);
}
catch (Exception ex)
{
Response.Write(ex.Message.ToString());
}
-------------------example how to use above code--------------
SmtpClient obj = new SmtpClient("smtp.gmail.com", 587);
//587 is the port number supplied by gmail team. we can use 456 also
obj.EnableSsl = true;
obj.Credentials = new System.Net.NetworkCredential("admg.fms@gmail.com","quantum123");
MailMessage Mailmsg = new MailMessage();
Mailmsg.To.Clear();
Mailmsg.From = new MailAddress("admg.fms@gmail.com");
Mailmsg.Subject = "Application rejected";
Mailmsg.Body = "Body";
//adding attachments
Attachment at = new Attachment(Server.MapPath("~/photo.jpg"));
Mailmsg.Attachments.Add(at);
Mailmsg.Priority = MailPriority.High;
Mailmsg.IsBodyHtml = true;
Mailmsg.To.Add(new MailAddress("kishoreswrn@gmail.com", "kishore"));
Mailmsg.BodyEncoding = System.Text.Encoding.Default;
try
{
obj.Send(Mailmsg);
}
catch (Exception ex)
{
Response.Write(ex.Message.ToString());
}
Response.Write("Mail Sent Successfully");
}
Friday, April 10, 2009
Network Basics
* Network - A network is a group of computers connected together in a way that allows information to be exchanged between the computers.
* Node - A node is anything that is connected to the network. While a node is typically a computer, it can also be something like a printer or CD-ROM tower.
* Segment - A segment is any portion of a network that is separated, by a switch, bridge or router, from other parts of the network.
* Backbone - The backbone is the main cabling of a network that all of the segments connect to. Typically, the backbone is capable of carrying more information than the individual segments. For example, each segment may have a transfer rate of 10 Mbps (megabits per second), while the backbone may operate at 100 Mbps.
* Topology - Topology is the way that each node is physically connected to the network (more on this in the next section).
* Local Area Network (LAN) - A LAN is a network of computers that are in the same general physical location, usually within a building or a campus. If the computers are far apart (such as across town or in different cities), then a Wide Area Network (WAN) is typically used.
* Network Interface Card (NIC) - Every computer (and most other devices) is connected to a network through an NIC. In most desktop computers, this is an Ethernet card (normally 10 or 100 Mbps) that is plugged into a slot on the computer's motherboard.
* Media Access Control (MAC) address - This is the physical address of any device -- such as the NIC in a computer -- on the network. The MAC address, which is made up of two equal parts, is 6 bytes long. The first 3 bytes identify the company that made the NIC. The second 3 bytes are the serial number of the NIC itself.
* Unicast - A unicast is a transmission from one node addressed specifically to another node.
* Multicast - In a multicast, a node sends a packet addressed to a special group address. Devices that are interested in this group register to receive packets addressed to the group. An example might be a Cisco router sending out an update to all of the other Cisco routers.
* Broadcast - In a broadcast, a node sends out a packet that is intended for transmission to all other nodes on the network.
Some of the most common topologies in use today include:
* Bus - Each node is daisy-chained (connected one right after the other) along the same backbone, similar to Christmas lights. Information sent from a node travels along the backbone until it reaches its destination node. Each end of a bus network must be terminated with a resistor to keep the signal that is sent by a node across the network from bouncing back when it reaches the end of the cable.
*Ring - Like a bus network, rings have the nodes daisy-chained. The difference is that the end of the network comes back around to the first node, creating a complete circuit. In a ring network, each node takes a turn sending and receiving information through the use of a token. The token, along with any data, is sent from the first node to the second node, which extracts the data addressed to it and adds any data it wishes to send. Then, the second node passes the token and data to the third node, and so on until it comes back around to the first node again. Only the node with the token is allowed to send data. All other nodes must wait for the token to come to them.
* Star - In a star network, each node is connected to a central device called a hub. The hub takes a signal that comes from any node and passes it along to all the other nodes in the network. A hub does not perform any type of filtering or routing of the data. It is simply a junction that joins all the different nodes together.
Star network topology
* Star bus - Probably the most common network topology in use today, star bus combines elements of the star and bus topologies to create a versatile network environment. Nodes in particular areas are connected to hubs (creating stars), and the hubs are connected together along the network backbone (like a bus network).
* Node - A node is anything that is connected to the network. While a node is typically a computer, it can also be something like a printer or CD-ROM tower.
* Segment - A segment is any portion of a network that is separated, by a switch, bridge or router, from other parts of the network.
* Backbone - The backbone is the main cabling of a network that all of the segments connect to. Typically, the backbone is capable of carrying more information than the individual segments. For example, each segment may have a transfer rate of 10 Mbps (megabits per second), while the backbone may operate at 100 Mbps.
* Topology - Topology is the way that each node is physically connected to the network (more on this in the next section).
* Local Area Network (LAN) - A LAN is a network of computers that are in the same general physical location, usually within a building or a campus. If the computers are far apart (such as across town or in different cities), then a Wide Area Network (WAN) is typically used.
* Network Interface Card (NIC) - Every computer (and most other devices) is connected to a network through an NIC. In most desktop computers, this is an Ethernet card (normally 10 or 100 Mbps) that is plugged into a slot on the computer's motherboard.
* Media Access Control (MAC) address - This is the physical address of any device -- such as the NIC in a computer -- on the network. The MAC address, which is made up of two equal parts, is 6 bytes long. The first 3 bytes identify the company that made the NIC. The second 3 bytes are the serial number of the NIC itself.
* Unicast - A unicast is a transmission from one node addressed specifically to another node.
* Multicast - In a multicast, a node sends a packet addressed to a special group address. Devices that are interested in this group register to receive packets addressed to the group. An example might be a Cisco router sending out an update to all of the other Cisco routers.
* Broadcast - In a broadcast, a node sends out a packet that is intended for transmission to all other nodes on the network.
Some of the most common topologies in use today include:
* Bus - Each node is daisy-chained (connected one right after the other) along the same backbone, similar to Christmas lights. Information sent from a node travels along the backbone until it reaches its destination node. Each end of a bus network must be terminated with a resistor to keep the signal that is sent by a node across the network from bouncing back when it reaches the end of the cable.
*Ring - Like a bus network, rings have the nodes daisy-chained. The difference is that the end of the network comes back around to the first node, creating a complete circuit. In a ring network, each node takes a turn sending and receiving information through the use of a token. The token, along with any data, is sent from the first node to the second node, which extracts the data addressed to it and adds any data it wishes to send. Then, the second node passes the token and data to the third node, and so on until it comes back around to the first node again. Only the node with the token is allowed to send data. All other nodes must wait for the token to come to them.
* Star - In a star network, each node is connected to a central device called a hub. The hub takes a signal that comes from any node and passes it along to all the other nodes in the network. A hub does not perform any type of filtering or routing of the data. It is simply a junction that joins all the different nodes together.
Star network topology
* Star bus - Probably the most common network topology in use today, star bus combines elements of the star and bus topologies to create a versatile network environment. Nodes in particular areas are connected to hubs (creating stars), and the hubs are connected together along the network backbone (like a bus network).
Open System Interconnection (OSI) Standards
How OSI Works
Introduction to How OSI Works
Virtually all networks in use today are based in some fashion on the Open Systems Interconnection (OSI) standard. OSI was developed in 1984 by the International Organization for Standardization (ISO), a global federation of national standards organizations representing approximately 130 countries.
The core of this standard is the OSI Reference Model, a set of seven layers that define the different stages that data must go through to travel from one device to another over a network. In this article, you'll find out all about the OSI standard.
The Layers
Think of the seven layers as the assembly line in the computer. At each layer, certain things happen to the data that prepare it for the next layer. The seven layers, which separate into two sets, are:
* Application Set
o Layer 7: Application - This is the layer that actually interacts with the operating system or application whenever the user chooses to transfer files, read messages or perform other network-related activities.
o Layer 6: Presentation - Layer 6 takes the data provided by the Application layer and converts it into a standard format that the other layers can understand.
o Layer 5: Session - Layer 5 establishes, maintains and ends communication with the receiving device.
* Transport Set
o Layer 4: Transport - This layer maintains flow control of data and provides for error checking and recovery of data between the devices. Flow control means that the Transport layer looks to see if data is coming from more than one application and integrates each application's data into a single stream for the physical network.
o Layer 3: Network - The way that the data will be sent to the recipient device is determined in this layer. Logical protocols, routing and addressing are handled here.
o Layer 2: Data - In this layer, the appropriate physical protocol is assigned to the data. Also, the type of network and the packet sequencing is defined.
o Layer 1: Physical - This is the level of the actual hardware. It defines the physical characteristics of the network such as connections, voltage levels and timing.
The seven layers of the OSI Reference Model
The OSI Reference Model is really just a guideline. Actual protocol stacks often combine one or more of the OSI layers into a single layer.
Protocol Stacks
A protocol stack is a group of protocols that all work together to allow software or hardware to perform a function. The TCP/IP protocol stack is a good example. It uses four layers that map to the OSI model as follows:
* Layer 1: Network Interface - This layer combines the Physical and Data layers and routes the data between devices on the same network. It also manages the exchange of data between the network and other devices.
* Layer 2: Internet - This layer corresponds to the Network layer. The Internet Protocol (IP) uses the IP address, consisting of a Network Identifier and a Host Identifier, to determine the address of the device it is communicating with.
* Layer 3: Transport - Corresponding to the OSI Transport layer, this is the part of the protocol stack where the Transport Control Protocol (TCP) can be found. TCP works by asking another device on the network if it is willing to accept information from the local device.
* Layer 4: Application - Layer 4 combines the Session, Presentation and Application layers of the OSI model. Protocols for specific functions such as e-mail (Simple Mail Transfer Protocol, SMTP) and file transfer (File Transfer Protocol, FTP) reside at this level.
As you can see, it is not necessary to develop a separate layer for each and every function outlined in the OSI Reference Model. But developers are able to ensure that a certain level of compatibility is maintained by following the general guidelines provided by the model.
To Remember all these layers we are having one code:
Please Do Not Touch Steve's Pet Alligator.
Please Refers to Physical Layer
Do Refers to Data Layer
Not Refers to Network Layer
Touch Refers to Transport Layer
Steve's Refers to Session Layer
Pet Refers to Presentation Layer
Alligator Refers to Application Layer
Introduction to How OSI Works
Virtually all networks in use today are based in some fashion on the Open Systems Interconnection (OSI) standard. OSI was developed in 1984 by the International Organization for Standardization (ISO), a global federation of national standards organizations representing approximately 130 countries.
The core of this standard is the OSI Reference Model, a set of seven layers that define the different stages that data must go through to travel from one device to another over a network. In this article, you'll find out all about the OSI standard.
The Layers
Think of the seven layers as the assembly line in the computer. At each layer, certain things happen to the data that prepare it for the next layer. The seven layers, which separate into two sets, are:
* Application Set
o Layer 7: Application - This is the layer that actually interacts with the operating system or application whenever the user chooses to transfer files, read messages or perform other network-related activities.
o Layer 6: Presentation - Layer 6 takes the data provided by the Application layer and converts it into a standard format that the other layers can understand.
o Layer 5: Session - Layer 5 establishes, maintains and ends communication with the receiving device.
* Transport Set
o Layer 4: Transport - This layer maintains flow control of data and provides for error checking and recovery of data between the devices. Flow control means that the Transport layer looks to see if data is coming from more than one application and integrates each application's data into a single stream for the physical network.
o Layer 3: Network - The way that the data will be sent to the recipient device is determined in this layer. Logical protocols, routing and addressing are handled here.
o Layer 2: Data - In this layer, the appropriate physical protocol is assigned to the data. Also, the type of network and the packet sequencing is defined.
o Layer 1: Physical - This is the level of the actual hardware. It defines the physical characteristics of the network such as connections, voltage levels and timing.
The seven layers of the OSI Reference Model
The OSI Reference Model is really just a guideline. Actual protocol stacks often combine one or more of the OSI layers into a single layer.
Protocol Stacks
A protocol stack is a group of protocols that all work together to allow software or hardware to perform a function. The TCP/IP protocol stack is a good example. It uses four layers that map to the OSI model as follows:
* Layer 1: Network Interface - This layer combines the Physical and Data layers and routes the data between devices on the same network. It also manages the exchange of data between the network and other devices.
* Layer 2: Internet - This layer corresponds to the Network layer. The Internet Protocol (IP) uses the IP address, consisting of a Network Identifier and a Host Identifier, to determine the address of the device it is communicating with.
* Layer 3: Transport - Corresponding to the OSI Transport layer, this is the part of the protocol stack where the Transport Control Protocol (TCP) can be found. TCP works by asking another device on the network if it is willing to accept information from the local device.
* Layer 4: Application - Layer 4 combines the Session, Presentation and Application layers of the OSI model. Protocols for specific functions such as e-mail (Simple Mail Transfer Protocol, SMTP) and file transfer (File Transfer Protocol, FTP) reside at this level.
As you can see, it is not necessary to develop a separate layer for each and every function outlined in the OSI Reference Model. But developers are able to ensure that a certain level of compatibility is maintained by following the general guidelines provided by the model.
To Remember all these layers we are having one code:
Please Do Not Touch Steve's Pet Alligator.
Please Refers to Physical Layer
Do Refers to Data Layer
Not Refers to Network Layer
Touch Refers to Transport Layer
Steve's Refers to Session Layer
Pet Refers to Presentation Layer
Alligator Refers to Application Layer
How OSI Works
Introduction to How OSI Works
Virtually all networks in use today are based in some fashion on the Open Systems Interconnection (OSI) standard. OSI was developed in 1984 by the International Organization for Standardization (ISO), a global federation of national standards organizations representing approximately 130 countries.
The core of this standard is the OSI Reference Model, a set of seven layers that define the different stages that data must go through to travel from one device to another over a network. In this article, you'll find out all about the OSI standard.
The Layers
Think of the seven layers as the assembly line in the computer. At each layer, certain things happen to the data that prepare it for the next layer. The seven layers, which separate into two sets, are:
* Application Set
o Layer 7: Application - This is the layer that actually interacts with the operating system or application whenever the user chooses to transfer files, read messages or perform other network-related activities.
o Layer 6: Presentation - Layer 6 takes the data provided by the Application layer and converts it into a standard format that the other layers can understand.
o Layer 5: Session - Layer 5 establishes, maintains and ends communication with the receiving device.
* Transport Set
o Layer 4: Transport - This layer maintains flow control of data and provides for error checking and recovery of data between the devices. Flow control means that the Transport layer looks to see if data is coming from more than one application and integrates each application's data into a single stream for the physical network.
o Layer 3: Network - The way that the data will be sent to the recipient device is determined in this layer. Logical protocols, routing and addressing are handled here.
o Layer 2: Data - In this layer, the appropriate physical protocol is assigned to the data. Also, the type of network and the packet sequencing is defined.
o Layer 1: Physical - This is the level of the actual hardware. It defines the physical characteristics of the network such as connections, voltage levels and timing.
The seven layers of the OSI Reference Model
The OSI Reference Model is really just a guideline. Actual protocol stacks often combine one or more of the OSI layers into a single layer.
Protocol Stacks
A protocol stack is a group of protocols that all work together to allow software or hardware to perform a function. The TCP/IP protocol stack is a good example. It uses four layers that map to the OSI model as follows:
* Layer 1: Network Interface - This layer combines the Physical and Data layers and routes the data between devices on the same network. It also manages the exchange of data between the network and other devices.
* Layer 2: Internet - This layer corresponds to the Network layer. The Internet Protocol (IP) uses the IP address, consisting of a Network Identifier and a Host Identifier, to determine the address of the device it is communicating with.
* Layer 3: Transport - Corresponding to the OSI Transport layer, this is the part of the protocol stack where the Transport Control Protocol (TCP) can be found. TCP works by asking another device on the network if it is willing to accept information from the local device.
* Layer 4: Application - Layer 4 combines the Session, Presentation and Application layers of the OSI model. Protocols for specific functions such as e-mail (Simple Mail Transfer Protocol, SMTP) and file transfer (File Transfer Protocol, FTP) reside at this level.
As you can see, it is not necessary to develop a separate layer for each and every function outlined in the OSI Reference Model. But developers are able to ensure that a certain level of compatibility is maintained by following the general guidelines provided by the model.
To Remember all these layers we are having one code:
Please Do Not Touch Steve's Pet Alligator.
Please Refers to Physical Layer
Do Refers to Data Layer
Not Refers to Network Layer
Touch Refers to Transport Layer
Steve's Refers to Session Layer
Pet Refers to Presentation Layer
Alligator Refers to Application Layer
Introduction to How OSI Works
Virtually all networks in use today are based in some fashion on the Open Systems Interconnection (OSI) standard. OSI was developed in 1984 by the International Organization for Standardization (ISO), a global federation of national standards organizations representing approximately 130 countries.
The core of this standard is the OSI Reference Model, a set of seven layers that define the different stages that data must go through to travel from one device to another over a network. In this article, you'll find out all about the OSI standard.
The Layers
Think of the seven layers as the assembly line in the computer. At each layer, certain things happen to the data that prepare it for the next layer. The seven layers, which separate into two sets, are:
* Application Set
o Layer 7: Application - This is the layer that actually interacts with the operating system or application whenever the user chooses to transfer files, read messages or perform other network-related activities.
o Layer 6: Presentation - Layer 6 takes the data provided by the Application layer and converts it into a standard format that the other layers can understand.
o Layer 5: Session - Layer 5 establishes, maintains and ends communication with the receiving device.
* Transport Set
o Layer 4: Transport - This layer maintains flow control of data and provides for error checking and recovery of data between the devices. Flow control means that the Transport layer looks to see if data is coming from more than one application and integrates each application's data into a single stream for the physical network.
o Layer 3: Network - The way that the data will be sent to the recipient device is determined in this layer. Logical protocols, routing and addressing are handled here.
o Layer 2: Data - In this layer, the appropriate physical protocol is assigned to the data. Also, the type of network and the packet sequencing is defined.
o Layer 1: Physical - This is the level of the actual hardware. It defines the physical characteristics of the network such as connections, voltage levels and timing.
The seven layers of the OSI Reference Model
The OSI Reference Model is really just a guideline. Actual protocol stacks often combine one or more of the OSI layers into a single layer.
Protocol Stacks
A protocol stack is a group of protocols that all work together to allow software or hardware to perform a function. The TCP/IP protocol stack is a good example. It uses four layers that map to the OSI model as follows:
* Layer 1: Network Interface - This layer combines the Physical and Data layers and routes the data between devices on the same network. It also manages the exchange of data between the network and other devices.
* Layer 2: Internet - This layer corresponds to the Network layer. The Internet Protocol (IP) uses the IP address, consisting of a Network Identifier and a Host Identifier, to determine the address of the device it is communicating with.
* Layer 3: Transport - Corresponding to the OSI Transport layer, this is the part of the protocol stack where the Transport Control Protocol (TCP) can be found. TCP works by asking another device on the network if it is willing to accept information from the local device.
* Layer 4: Application - Layer 4 combines the Session, Presentation and Application layers of the OSI model. Protocols for specific functions such as e-mail (Simple Mail Transfer Protocol, SMTP) and file transfer (File Transfer Protocol, FTP) reside at this level.
As you can see, it is not necessary to develop a separate layer for each and every function outlined in the OSI Reference Model. But developers are able to ensure that a certain level of compatibility is maintained by following the general guidelines provided by the model.
To Remember all these layers we are having one code:
Please Do Not Touch Steve's Pet Alligator.
Please Refers to Physical Layer
Do Refers to Data Layer
Not Refers to Network Layer
Touch Refers to Transport Layer
Steve's Refers to Session Layer
Pet Refers to Presentation Layer
Alligator Refers to Application Layer
To change the image dynamically in crystal reports
If you are using Crystal Reports XI or later you can do this programatically using the 'Graphic Location' conditional formula.
To do this, perform the following steps:
1. Open the report in the Crystal Reports Designer.
2. Create a formula called "Location" that contains a temporary path string to an image file. For example, "C:\Images\Image1.jpg".
3. Right-click the image on the report and click 'Format Graphic'. The 'Format Editor' dialog box appears.
4. In the 'Picture' tab, click the 'Graphic Location' conditional formula button. The Format Formula Editor appears.
5. Call the "Location" formula from this conditional formula.
6. Save changes to the report.
7. In your application, you can now change the location of the image file at run time, by modifying the text in the "Location" formula programmatically using the following code:
myReport.DataDefinition.FormulaFields.Item("Location").Text = "C:\Images\Image2.jpg"
You can now view the image successfully when previewing your report in the application.
To do this, perform the following steps:
1. Open the report in the Crystal Reports Designer.
2. Create a formula called "Location" that contains a temporary path string to an image file. For example, "C:\Images\Image1.jpg".
3. Right-click the image on the report and click 'Format Graphic'. The 'Format Editor' dialog box appears.
4. In the 'Picture' tab, click the 'Graphic Location' conditional formula button. The Format Formula Editor appears.
5. Call the "Location" formula from this conditional formula.
6. Save changes to the report.
7. In your application, you can now change the location of the image file at run time, by modifying the text in the "Location" formula programmatically using the following code:
myReport.DataDefinition.FormulaFields.Item("Location").Text = "C:\Images\Image2.jpg"
You can now view the image successfully when previewing your report in the application.
Wednesday, April 8, 2009
Code for file upload control
protected void Button1_Click(object sender, EventArgs e)
{
if (FileUpload1.FileContent.Length > 0)
{
FileUpload1.SaveAs(Server.MapPath("dmg_Images") + "\\" + System.IO.Path.GetFileName(FileUpload1.FileName));
}
HiddenField1.Value = Server.MapPath("dmg_Images") + "\\" + System.IO.Path.GetFileName(FileUpload1.FileName);
Image2.ImageUrl = "~/NewFolder1/dmg_Images/" + System.IO.Path.GetFileName(FileUpload1.FileName);
}
{
if (FileUpload1.FileContent.Length > 0)
{
FileUpload1.SaveAs(Server.MapPath("dmg_Images") + "\\" + System.IO.Path.GetFileName(FileUpload1.FileName));
}
HiddenField1.Value = Server.MapPath("dmg_Images") + "\\" + System.IO.Path.GetFileName(FileUpload1.FileName);
Image2.ImageUrl = "~/NewFolder1/dmg_Images/" + System.IO.Path.GetFileName(FileUpload1.FileName);
}
To disable the crystal report login credentials
using CrystalDecisions.Shared;
using CrystalDecisions.CrystalReports.Engine;
ReportDocument rpt;
------in page load-------
ConfigureCrystalReports("Datewise.rpt");
CrystalReportViewer1.DataBind();
--------copy and paste these two below functions----------
private void ConfigureCrystalReports(string path)
{
rpt = new ReportDocument();
string reportPath = Server.MapPath(path);
rpt.Load(reportPath);
ConnectionInfo connectionInfo = new ConnectionInfo();
connectionInfo.DatabaseName = "fms_new";
connectionInfo.UserID = "sa";
connectionInfo.Password = "sa";
SetDBLogonForReport(connectionInfo, rpt);
CrystalReportViewer1.ReportSource = rpt;
}
private void SetDBLogonForReport(ConnectionInfo connectionInfo, ReportDocument reportDocument)
{
Tables tables = reportDocument.Database.Tables;
foreach (CrystalDecisions.CrystalReports.Engine.Table table in tables)
{
TableLogOnInfo tableLogonInfo = table.LogOnInfo;
tableLogonInfo.ConnectionInfo = connectionInfo;
table.ApplyLogOnInfo(tableLogonInfo);
}
}
using CrystalDecisions.CrystalReports.Engine;
ReportDocument rpt;
------in page load-------
ConfigureCrystalReports("Datewise.rpt");
CrystalReportViewer1.DataBind();
--------copy and paste these two below functions----------
private void ConfigureCrystalReports(string path)
{
rpt = new ReportDocument();
string reportPath = Server.MapPath(path);
rpt.Load(reportPath);
ConnectionInfo connectionInfo = new ConnectionInfo();
connectionInfo.DatabaseName = "fms_new";
connectionInfo.UserID = "sa";
connectionInfo.Password = "sa";
SetDBLogonForReport(connectionInfo, rpt);
CrystalReportViewer1.ReportSource = rpt;
}
private void SetDBLogonForReport(ConnectionInfo connectionInfo, ReportDocument reportDocument)
{
Tables tables = reportDocument.Database.Tables;
foreach (CrystalDecisions.CrystalReports.Engine.Table table in tables)
{
TableLogOnInfo tableLogonInfo = table.LogOnInfo;
tableLogonInfo.ConnectionInfo = connectionInfo;
table.ApplyLogOnInfo(tableLogonInfo);
}
}
Subscribe to:
Comments (Atom)