|
|
windows server 2003 x64
by Satalaj
4. February 2010 08:29
After doing lots of troubleshooting to install ODBC drivers on windows 2003 OS machine, I found that it was 64 bit where I was trying to
install 32 bit ODBC Drivers.
well, here is command to know what type of CPU architecture you have.
Open a command prompt and execute systeminfo.exe
C:\>systeminfo.exe
Host Name: xxx
OS Name: Microsoft Windows XP Professional
OS Version: 5.1.2600 Service Pack 3 Build 2600
OS Manufacturer: Microsoft Corporation
OS Configuration: Member Workstation
OS Build Type: Multiprocessor Free
Registered Owner:
Registered Organization:
Product ID:
Original Install Date: 11/16/2005, 3:10:01 PM
System Up Time: 0 Days, 3 Hours, 39 Minutes, 28 Seconds
System Manufacturer: Gigabyte Technology Co., Ltd.
System Model: 945GCMX-S2
System type: X86-based PC
Processor(s): 1 Processor(s) Installed.
Below are the results for 64 bit machine
C:\Documents and Settings\Administrator>systeminfo.exe
Host Name: xxxx-xxxx
OS Name: Microsoft(R) Windows(R) Server 2003 Enterprise x64 E
ition
OS Version: 5.2.3790 Service Pack 2 Build 3790
OS Manufacturer: Microsoft Corporation
OS Configuration: Standalone Server
OS Build Type: Multiprocessor Free
Registered Owner: xxx
Registered Organization: xxx
Product ID:
Original Install Date: 4/3/2008, 6:39:26 AM
System Up Time: 0 Days, 3 Hours, 29 Minutes, 11 Seconds
System Manufacturer:
System Model: AWRDACPI
System Type: x64-based PC
Processor(s): 2 Processor(s) Installed.
Systeminfo.exe is very useful command to know your PC configuration and Service pack info etc.
Before downloading any software make sure that you are downloading correct version or edition which supports your CPU architecture.
Satalaj
Error: The SSIS Runtime has failed to start the distributed transaction due to error 0x8004D01B "The Transaction Manager is not available.". The DTC transaction failed to start. This could occur because the MSDTC Service is not running.
by Satalaj
2. February 2010 08:52
If you are using transaction in SSIS packages, you may encounter with this error.
Quick fix
Open you .net command prompt type
MSDTC -install
After installing MSDTC, service you need to start it using below command
Net Start MSDTC
well, you can use Net start or Net stop to start and stop an services
Satalaj
Connection pooling
by Satalaj
29. January 2010 12:16
Hi, my name is Satalaj. Here, I'm going to explain what is connection pool with solid proof.
Connection pool as name suggest its a pool of Established connections.
When we are closing the connection in finally or in try catch block that doesn't mean we are closing Established connection with your db server.
Closing connection means notifying the application about that connection is free for future request.
Here, I will tell my connection string to use min pool size = 1 and max pool size = 2.
As soon as pool gets initialized it will establish only one connection with SQL server db.
You can use below query to test how many connections are established with your MS SQL db server. I established the connection with asptest DB.
select db_name(dbid) as DataBaseName , count(dbid) as
NoOFConnections , loginame as LoginName
from sys.sysprocesses where dbid > 0 and db_name(dbid) = 'apitest'
group by dbid,loginame
Here is screen shot of Established connection.
I fired a command netstat -b from my command prompt and found that WindowsApplication1.VShost.exe with process ID 6140
Established one connection with MS SQL server IP 192.168.1.1.28 on port 1433.
My application is running and it has processed his task and I have closed the connection. However, you can see the connection is Established
and it will stay established, still the life of application. If I colse the application, I will not see any connection with my DB APITEST.
TCP smartmirror:2096 192.168.1.28:ms-sql-s ESTABLISHED 6140
[WindowsApplication1.vshost.exe]
In my application I have one established connection. What will happen If I get 2 requests simultaniouesly?
Ans. The application will establish another connection to DB server as my Max pool size is 2 and that new connection will serve the request.
What if I get 3 or 4 simultaneous requests?
If there is no free connection available in connection pool the application will throw an error
Timeout expired. The timeout period elapsed prior to obtaining a connection from the pool. This may have occurred because all pooled connections were in use and max pool size was reached.
What happens when I set Min pool size = 10 in my connection string ?
The application will establish 10 connection with DB.
You can see it by using query above and at client / server side, you can execute netstat -a command to know
which are the ports participates in this communication. You can see how my application is talking to sql server using ports ranging from 3979 to 3988.
TCP smartmirror:3979 192.168.1.28:ms-sql-s ESTABLISHED
TCP smartmirror:3980 192.168.1.28:ms-sql-s ESTABLISHED
TCP smartmirror:3981 192.168.1.28:ms-sql-s ESTABLISHED
TCP smartmirror:3982 192.168.1.28:ms-sql-s ESTABLISHED
TCP smartmirror:3983 192.168.1.28:ms-sql-s ESTABLISHED
TCP smartmirror:3984 192.168.1.28:ms-sql-s ESTABLISHED
TCP smartmirror:3985 192.168.1.28:ms-sql-s ESTABLISHED
TCP smartmirror:3986 192.168.1.28:ms-sql-s ESTABLISHED
TCP smartmirror:3987 192.168.1.28:ms-sql-s ESTABLISHED
TCP smartmirror:3988 192.168.1.28:ms-sql-s ESTABLISHED
It proves that I have 10 Established connections with SQL server and my application.
when I tell the connection object to close the connection, It only notifies the application about that "free connection", which can be used to serve next request.
When I tell connection object to open a connection I get a free connection form connection pool.
To know more about, how clients talks to the server refer http://revenmerchantservices.com/post/2010/01/25/client-server-communication.aspx
You can have multiple pools in applications. Of Course, there is a limit as there is limits on available ports ranging from 0 to 65535.
Its best practice not to have connection string opened in infinite time to serve the request. If you let the connection opened for infinite loop
your application will not be able to serve other requests. you can try it yourself by setting min and max pool size of your connection string.
By default min pool size is 0 and max pool size is 100.
Conclusion: I told connection object to open a connection with SQL DB server means I'm telling connection object to setup actual connection with DB server?
No, I'm telling the connection object to get the already established free connection from connection pool.
I hope you understood the location of Connection Pool and its importance.
Satalaj.
client server communication
by Satalaj
25. January 2010 03:47
I was wondering to know how two computers can communicate with each other then I came to know its a client and server who are responsible to setup that communication.
Well, client and server both are applications or you can say computer programs.
Server: Its an application which listens on port and serves the request.
Client: It's also an application who sends a request to server on particular port.
Lets take an example of web, where browser (IE, FF) are clients who sends the request to server on port 80.
On server, there are multiple applications who listens on particular port, like IIS service listens on port 80 where SQL server listens on port 1433.
First browser should know the location of server. That's nothing but the IP address of SERVER.
Only one application can listens on port 80 it can be a IIS or Apache. Both applications can't listens on same port. That's why, if we tell the IIS to
listen on port 80 we need to tell Apache to listen on different port like 8080. So when request came to port 80, IIS will serve that request
and when request came to port 8080 Apache will serve that request.
If we are having two IP addresses assigned to the server then for IP address 192.168.1.1 we can tell the IIS to listen on port 80
and for IP address 192.168.1.2 we can tell Apache to listen on port 80. In this case requests coming to IP 192.168.1.1 port 80 will
get served by IIS and requests coming on 192.168.1.2 port 80 will get served by Apache. This is how we can resolve the conflicts.
Lets talk about how Client communicates with server.
E.g.
Suppose, your IE requests a page http://www.google.com/. It will start establishing the communication with http://www.googe.com/.
During this time if you are trying to request another page of http://www.google.com/ it will establish another connection with server.
In first case, client needs to open a port with server lets say 1001 is opened to communicate with server and this port is engaged.
Means communication is not established yet. As 1001 is engaged second request opens next port 1002 with server and start communicating.
Server establishes the communication with port 1001 and responds to client on port 1001, for second request it responds to client
on port 1002.
You can use netstat command from command prompt to see foreign IP address , ports and local IP address, ports.
It also tell us the state of communication whether its established or waiting for server to respond.
TCP smartmirror:1455 bom01s01-in-f86.1e100.net:http CLOSE_WAIT
TCP smartmirror:1495 digsby04.rit.edu:5222 ESTABLISHED
TCP smartmirror:1497 69.46.36.6:http ESTABLISHED
TCP smartmirror:1501 bom01s01-in-f99.1e100.net:http ESTABLISHE
TCP smartmirror:1502 bom01s01-in-f147.1e100.net:http ESTABLISH
Here smartmirror is my local IP and 1497 is my local port who established connection with foreign IP 69.46.36.6 on port http (80)
Conclusion:
When clients talks with server on port, it doesn't mean that clients needs to have port 80 open at his end.
Clients open the available port 1455 at his end and send requests to server on port 80. Server sends a response to client on
client side port 1455.
The detailed list of available port can be see here http://www.iana.org/assignments/port-numbers
There exists 0 to 65535 ports out of these ports, ports ranging from 49152 to 65535 are available for
dynamic or private ports.
I hope you got clear idea of how client communicates with server.
Satalaj
http://www.satalaj.com/
C# html Parser
by Satalaj
22. January 2010 10:44
If you came here by searching for C#.net or VB.net html parser, your search ends here.
While developing screen scrapping with C#.net, I came across very rich open source HtmlParser. Who is capable of parsing entire html document.
Here is a link to download and parse the required fields in html http://www.codeplex.com/htmlagilitypack.
It is very similar to librarys provided by .net to parse or iterate XMLDocuments.
code snippet:
It will give you list of all nodes of type Input. Here str is your actual HTML string that you received in HttpWebResponse object
HtmlAgilityPack.HtmlDocument hd = new HtmlAgilityPack.HtmlDocument();
hd.LoadHtml(str);
HtmlNodeCollection hc = hd.DocumentNode.SelectNodes("//input");
You can use Xpath query to iterate nodes and ChildNodes.
Satalaj
screen scrapping asp.net pages
by Satalaj
22. January 2010 10:19
If you want to crawl asp.net pages using HttpWebRequest and HttpWebResponse, you need to POST the __VIEWSTATE, EVENTARGUMENT and EVENTTARGET
along with your Request.
If that page stores session or cookies you need to pass session cookies and Cookies along with the HttpWebRequest object.
You need to use Post Method.
your post data will look like this
string postData = "__EVENTARGUMENT=" + value + "&_EVENTTARGET="+ targetValue+ "&__VIEWSTATE="+ViewState ;
You first use tools like fiddler to know how your broser post the data to .aspx pages then prepare your post string to post the data.
Satalaj
Server.Transfer vs Response.Redirect
by Satalaj
21. January 2010 10:50
Use Server.Transfer. whereever it is possible, use the Server.Transfer method instead of the Response.Redirect method.
Response.Redirect sends a response header to the client that causes the client to send a new request to the redirected server by using the new URL.
If you have tools installed like fiddler you can easily see what has been posted back inside Header to the clients like IE.
Its a Status code 302 and header contains location of resource.
Server.Transfer avoids this level of redirection by simply making a server-side call.
You cannot always just replace Response.Redirect calls with Server.Transfer calls because Server.Transfer uses a new handler during the handler phase of request processing.
If you need authentication and authorization checks during redirection, use Response.Redirect instead of Server.Transfer because the two mechanisms are not equivalent and
as you know during authontication we check wheather cookie exists in Request or not. There we must use Response.Redirect.
When you use Response.Redirect, ensure you use the overloaded method that accepts a Boolean second parameter, and pass a value of false to ensure an internal exception is not raised.
You can see that exception by simply putting Try catch Blocks in your application. To avoid internal exception pass second parameter as false.
Also note that you can only use Server.Transfer to transfer control to pages in the same application. To transfer to pages in other applications, you must use Response.Redirect.
That means you can't call the pges residing outside of your application domain. like http://bing.com http://google.com www.asp.net can't put inside your server.transfer method.
Satalaj
Configuration Error
by Satalaj
20. January 2010 11:14
How will you fix this error? read more.
Configuration Error
Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.
Parser Error Message: Unrecognized attribute 'restartOnExternalChanges'.
Line 2: <configuration>
Line 3: <configSections>
Line 4: <section name="tConfigurationSection" type="someapp, someapp.Core" allowDefinition="MachineToApplication" restartOnExternalChanges="true"/>
Line 5: </configSections>
Line 6: <connectionStrings>
Source File: C:\Dot net Project\my.API\some.Web\web.config Line: 4
--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:1.1.4322.2300; ASP.NET Version:1.1.4322.2300
Fix 1. You don;t have installed the .net framework 2.0 on that machine.
Fix 2. You need to tell IIS to use ASP.net 2.0 envirnment and not ASp.net 1.1 to run your asp.net 2.0 web application.
Satalaj
HTTP Error 404 - File or directory not found.
by Satalaj
19. January 2010 05:09
Scenario, you installed the IIS 6.0 and framework 2.0 on windows 2003 operating system. After deploying the web you observed that web is
responding an error with 404.
By default, once you installed the IIS. It want not allow to run ASP.net or web pages or CGI, perl etc.
you need to allow them to fix this error. You need to open IIS 6.0 and find the node called Web services extensions.
In right pen you can allow or prohibit the access to ASP.net 2.0 or CGI.
For more information you can refer below link
http://www.microsoft.com/technet/prodtechnol/WindowsServer2003/Library/IIS/44f16c37-f727-4244-9813-2289e13dadba.mspx?mfr=true
or you can use support forum at www.iis.net
The default IIS settings will allow you to only see the Static pages.

Satalaj
Connection pooling
by Satalaj
16. January 2010 05:24
I found very interesting article on connection pooling in ASP.net.
If you want to understand what is connection pooling,
refer http://ondotnet.com/pub/a/dotnet/2004/02/09/connpool.html
It gives solid proof of what exactly happens when you open connection with your Data base server using ADO.net
default size of pool is 100.
you can also check with below query and perform the tests described in that article.
Using below query you can check number of connections opened to database and who opened it etc..
select db_name(dbid) as DataBaseName , count(dbid) as NoOFConnections , loginame as LoginName from sys.sysprocesses
where dbid > 0
group by dbid,loginame
SELECT spid, uid=rtrim(loginame), Program_name=rtrim(Program_name),
dbname=db_name(dbid), status=rtrim(status) FROM master.dbo.sysprocesses
WHERE loginame = 'sa' and db_name(dbid) = 'APITest'
order by dbname
To know, which connction string I should use with what data base providers.
refer www.connectionstrings.com
Satalaj
|