Constant
const field can never be modified and must be initialized where it is declared
class Company
{
public const string CompanyName = "RK Inc";
}
Static Readonly
class Company
{
public static readonly string CompanyName = "RK Inc";
staticCompany()
{
CompanyName = "My Company";
}
}
Assigning the value to a readonly field outside the class will throw the following error:
Company.CompanyName = "My Company";
A static readonly field cannot be assigned to (except in a static constructor or a variable initializer)
MSMQ Format Name and Host Name
General MSMQ Format Names:
QueueInfo.FormatName = "DIRECT=Protocol:Address\Queue"
QueueInfo.FormatName = "DIRECT=OS:ComputerName\Queue"
QueueInfo.FormatName = "PUBLIC=QueueGUID"
QueueInfo.FormatName = "PRIVATE=ComputerGUID\Queue"
Sample pathnames and direct format names for both public and private queues.
| Path Names | |
| .\RKQueue | References a public queue named RKQueue on the local machine. |
| server01\RKQueue | References a public queue named RKQueue on a machine named server01 (local queues can be referenced with a machine name as well). |
| .\private$\RKQueue | References a private queue named RKQueue on the local machine. |
| server01\private$\RKQueue | References a private queue named RKQueue on a machine named server01. |
| Direct Format Names | |
| Formatname:DIRECT=OS:.\RKQueue | References a public queue named RKQueue on the local machine. |
| Formatname:DIRECT=OS:server01\RKQueue | References a public queue named RKQueue on a machine named server01. |
| Formatname:DIRECT=TCP:127.0.0.1\private$\RKQueue | References a private queue named RKQueue on the local machine. |
FormatName:Public= 5A5F7535-AE9A-41d4-935C-845C2AFF7112
FormatName:DIRECT=SPX: NetworkNumber; HostNumber\QueueName
FormatName:DIRECT=TCP: IPAddress\QueueName
FormatName:DIRECT=OS: MachineName\QueueName
"PRIVATE=ComputerGUID\Queue"
FormatName:DIRECT=http://<client name>/msmq/<queue name>
FormatName:DIRECT=https://<client name>/msmq/<queue name>
Advantage of SQL Server .NET data provider
ADO.NET provides several different methods to access SQL Server data, including OLE DB.NET, ODBC.NET, SQLXML, and the SQL Server .NET data provider. Of all of these, the SQL Server .NET data provider is the fastest, as much as 30-40% faster than the others. The SQL Server .NET provider uses TDS (Tabular Data Stream, which is the native SQL Server data format) to communicate with SQL Server.
IP address in ADO.NET connection string
When you specify a server in an ADO.NET connection string, use the server's IP address, not the server's DNS name. By using an IP address instead of a DNS name, name resolution does not have to occur, reducing the amount of time it takes for a connection to be made. A server's IP address can be used to specify either a default or named instance of a server running SQL Server. If you are running a cluster, use the virtual SQL Server IP address.
Subscribe to:
Posts (Atom)