C Sharp 2010 Ebook (pdf) Free download Thursday, Nov 11 2010 

C Sharp 2010 Ebook Free download click here

Advertisements

Download free ebook of ASP.Net 4.0 Step By Step Thursday, Nov 11 2010 

To download free ebook of ASP.Net 4.0 step by step click here.

The Attributes of a Connection String in ASP.Net with C# Thursday, Nov 11 2010 

To use a SqlConnection object, you must provide various pieces of information joined into a string but are separated from each other with a semi-colon “;”. Each piece appears as a Key=Value:

Key1=Value1;Key2=Value2;Key_n=Value_n

It can be passed as follows:

SqlConnection connection = new SqlConnection("Key1=Value1;Key2=Value2;Key_n=Value_n");

or assigned as a string to the SqlConnection.ConnectionString property:

string strConnection = "Key1=Value1;Key2=Value2;Key_n=Value_n";
SqlConnection connection = new SqlConnection();

connection.ConnectionString = strConnection;

The Source of Data

To establish a connection, you must specify the computer you are connecting to, that has Microsoft SQL  Server installed. If you are creating your application on the same computer on which SQL Server is  installed, you can use (local). Here is an example:
SqlConnection connection = new SqlConnection("Server=(local); ");

If you know the name of the computer, you can assign it to the computer attribute. Here is an example:

SqlConnection connection = new SqlConnection("Server=central; ");

In the same way, if you are connecting to a specific computer, you must provide its name. Here is an

example:

SqlConnection connection = new SqlConnection("Data Source=central; ")

Security

An important aspect of establishing a connection to a computer is security. To support security, the

connection string of the SqlConnection class includes an attribute called Trusted_Connection orIntegrated

Security that can have a value of truefalseyesno, or SSPI with the SSPI having the same indication

as true.

If you are establishing a trusted or simple connection that doesn't need to be verified, you can assign

a value of true or SSPI.  Here is an example:

SqlConnection connection =
        new SqlConnection("Server=(local);Trusted_Connection=SSPI");

If you are programmatically establishing the connection, to apply authentication, you can assignfalse or

no to the security attribute you selected.

The Username

To specify the user name, after assigning false or no to the security attribute, you must use theUser ID

attribute and assign it a valid username. Here is an example:

string strConnection = "Server=(local);" +
                           "Integrated Security=no;" +
                           "User ID=wmessmann";
    SqlConnection connection = new SqlConnection(strConnection);

The Password

Besides the username, to create a secured connection, you must also provide a password. To specify the

password, you can user either the PASSWORD or the PWD. Here is an example:

string strConnection = "Server=(local);" +
                           "Integrated Security=no;" +
                           "User ID=wmessmann;PWD=$outh~@kotA";
    SqlConnection connection = new SqlConnection(strConnection);

The Database

To specify the database, the connection string includes an attribute named Database. TheDatabase keyword

can also be substituted for the Initial Catalog value. Here is an example:

SqlConnection connection = new SqlConnection(Server=(local);Database=;);

Another alternative is to assign an empty, single-quoted, string to this attribute. Here is an example:

void InitializeComponent()
{
    string strConnection = "Server=(local);Initial Catalog='exercise1';";
    SqlConnection connection = new SqlConnection(strConnection);
}

As mentioned above, the Database attribute is optional, especially if you are only connecting to the

computer and not to a specific database.

Additional Attributes

There are various other attributes used in the connection string. They include Network Library(also

called Net), Application NameWorkstation IDEncryptConnection TimeoutData SourcePacket Size,

AttachDBFilenameCurrent LanguagePersist Security Info.

After creating the connection string, when the application executes, the compiler would "scan" the string

to validate each key=value section. If it finds an unknown Key, an unknown value, or an invalid

combination of key=value, it would throw an ArgumentException exception and the connection cannot be

established.
Reference: http://www.functionx.com/aspnet/sqlserver/Lesson01.htm
 

Get URL Parameters (QueryStrings) using Javascript Wednesday, Nov 10 2010 

Nearly all server-side programming languages have built-in functions to retrieve querystring values of a URL. In web browsers you can access the querystring with client-side JavaScript, but there is no standard way to parse out the name/value pairs. So here is afunction to return a parameter you specify. The following javascript code snippet facilitates Javascript’s built in regular expressions to retrieve value of the key. Optionally, you can specify a default value to return when key does not exist.

function getQuerystring(key, default_)
{
if (default_==null) default_=””;
key = key.replace(/[\[]/,”\\\[“).replace(/[\]]/,”\\\]”);
var regex = new RegExp(“[\\?&]”+key+”=([^&#]*)”);
var qs = regex.exec(window.location.href);
if(qs == null)
return default_;
else
return qs[1];
}

The getQuerystring function is simple to use. Let’s say you have the following URL:

http://www.bloggingdeveloper.com?author=bloggingdeveloper

and you want to get the “author” querystring’s value:

var author_value = getQuerystring(‘author’);

 

Reference: http://www.bloggingdeveloper.com/post/JavaScript-QueryString-ParseGet-QueryString-with-Client-Side-JavaScript.aspx

SQL Server Interview Questions and Answers ebook free download Wednesday, Nov 10 2010 

SQL Server Interview Questions and Answers ebook free download click here.

How and what is the use of a abstract class constructor? Wednesday, Nov 10 2010 

As we know a abstract class can not be instantiated.

But sometimes we need to call a constructor of abstract class. An abstract class may have constructors to initialize methods or pass values along to base class constructors.

 

 

Example:

 

using System;
public class HelloWorld
{
public static void Main()
{
Person hs = new Person(“Hitesh”,“Seth”);
Console.WriteLine(hs.GetFullName());
}
}
abstract public class Abstract
{
protected string FirstName, LastName;
public Abstract(string FirstName, string LastName)
{
this.FirstName = FirstName;
this.LastName = LastName;
}
abstract public string GetFullName();
}
public class Person : Abstract
{
public Person(string FirstName, string LastName) : base(FirstName, LastName)
{
}
public override string GetFullName()
{
return FirstName+“.”+LastName;
}
}