Click here to Skip to main content
15,891,943 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
I need line by line explanation for following codings.kindly request to send the solution as early as possible.
C#
namespace RunTimeDefenceAgainstCodeInjectionAttack
{
   static class genModule
   {
      public static SqlConnection con = 
           new SqlConnection("server=.;uid=sa;database=RunTimeDefenceAgainstCodeInjectionAttack");
      
      //public con As New OleDbConnection("Server=.;database=OnFairness;user id=sa;password=") 
      public static SqlCommand cmd = new SqlCommand("", con);
      //public static bool startmonitor = false;
   }
}
Posted
Updated 26-Jul-16 18:36pm
v3

C#
// Identify the namespace for this code module
namespace RunTimeDefenceAgainstCodeInjectionAttack
{
   // Create a static class with the name genModule
   static class genModule
   {
      // Create a SqlConnection object to connection to the "RunTimeDefenceAgainstCodeInjectionAttack" database.
      public static SqlConnection con =
           new SqlConnection("server=.;uid=sa;database=RunTimeDefenceAgainstCodeInjectionAttack");

      //This line is commented out and will not be compiled.
      //public con As New OleDbConnection("Server=.;database=OnFairness;user id=sa;password=")

      // Create a SqlCommand object that can be used to generate and execute queries against the connection "con" which was created above.
      public static SqlCommand cmd = new SqlCommand("", con);

      //This line is commented out and will not be compiled.
      //public static bool startmonitor = false;
   }
}
 
Share this answer
 
v4
Comments
Shahin Khorshidnia 23-Mar-12 13:27pm    
+5
fjdiewornncalwe 23-Mar-12 13:52pm    
Thank you, Shahin
RaisKazi 23-Mar-12 21:03pm    
Kind answer. 5ed.
fjdiewornncalwe 2-Apr-12 10:24am    
Thanks
ProEnggSoft 30-Mar-12 19:45pm    
Nice explanation. +5
On the connection string:

"server=.;uid=sa;database=RunTimeDefenceAgainstCodeInjectionAttack"


The sever=. means that the server is on the local machine.

The uid=sa means that the user id is sa, which also mean that you are not using something like Windows authentication, but using the database authentication

The database=RunTimeDefenceAgainstCodeInjectionAttack means that the database name that is specified is RunTimeDefenceAgainstCodeInjectionAttack

To see description of all connection string attributes goto http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlconnection.connectionstring.aspx[^]
 
Share this answer
 
Comments
fjdiewornncalwe 23-Mar-12 15:15pm    
Nice addition. +5.
RaisKazi 23-Mar-12 21:03pm    
My 5.
C#
private static List MapList(DataTable dt)
{
	List list = new List();

	FieldInfo[] fields = typeof(T).GetFields();
	T t = Activator.CreateInstance();

	foreach (DataRow dr in dt.Rows)
	{
		foreach (FieldInfo fi in fields)
			fi.SetValueDirect(__makeref(t), dr[fi.Name]);

		list.Add(t);
	}

	return list;
}


Can anyone please explain me the above code..
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900