Friday, March 28, 2008

SQL Sever 2005: Connection Fail when connecting to the server using SQL credentials

Incase you are un-able to login to SQL server using SQL Credentials, then try the following;
1. Check if the user name exists in the SQL server.
2. Check if the password is expired / account locked.
3. Incase you get a error something like "Login failed for user 'XXXX'. The user is not associated with a trusted SQL server connection", then check the SQL server Authentication mode(it might be using only Windows Authentication". To check the authentication follow below steps;
a. Login into the SQL server using windows credentials.
b. Right click the SQL server and go to properties.
c. Goto "Security" tab.
d. Ensure "SQL Server and Windows Authentication mode" is selected in Server Authentication section.

e. Click OK.
f. Restart the SQL server service.


Hope this helps somebody.....

Wednesday, March 26, 2008

NAnt how to...(for beginners)

Installation
NAnt is available in either a source or binary distribution. The binary distribution is all you need to use NAnt to build your projects, including creating your own custom tasks, types and functions.
If you are upgrading NAnt from a previous version, you must never install over the top of your previous installation. Delete or rename the existing installation directory before installing the new version of NAnt.

Installing from binaries
1. Download the binary distribution archive. Either nant-bin.zip or nant-bin.tar.gz, the contents of each archive are the same. http://nant.sourceforge.net/
2. Remove any previous versions of NAnt you may have installed.
3. Extract the contents of the archive to the location you wish to install NAnt (eg: C:\Program Files\NAnt in windows, or /usr/local/nant in Linux)
4. Depending on your environment, create a wrapper script to run NAnt

SET Environment Variables
To set environment variables follow the below steps:
1. Goto System Properties->Advanced. Click the tab named “Environment Variables”.

2. Add new entry for NAnt as below


Variable value is the path where NAnt.exe is installed.
Creating Default.Build File
1. Create NAnt Build file something similar to the below screen shot.
2. Build File is a XML with a file extension “BUILD”. This file contains the build information that needs to be processed by NAnt.
A Sample Build file is as below

Note: The build file has to have the tag. Else NAnt will throw out error stating “Build Failed – Root Element missing”
Verifying the Installation
1. Once the build file is created.
2. Using the command window, Open the directory where the NAnt.exe resides, in this case it is “C:\nant-0.86-beta1\bin”.
3. Run Nant (see below)
4. You should get see the output “Build Succeeded” message.

Adding contents to the Build File
1. Once the build file is successful. We could start adding the adding the build script.
2. Example: Lets add a script to open a Notepad window from NAnt. Add the following code in the build file as “



Your final file would looks something like below

Executing the Build
1. Open the command window go to the NAnt.exe folder and execute the following
NAnt run2
Where run2 happens to be the “Target” name in the Temp.Build file.

2. Immediately you should be able to see a new notepad window open up.

Tuesday, March 25, 2008

How to pass information via SoapHeader in WebService

Today i found a intresting article regarding How to Pass Information via Soap Header in WebService.
Please visit the below link for more information....
 
 

Wednesday, March 19, 2008

How to convert String to Byte and upload to SQL DB column having datatype as Image..

string strImageName=string.Empty;
strImageName="Hi, This is Test String";
//Assigning string as Byte
byte[] byImageName=(new ASCIIEncoding()).GetBytes(strImageName.ToString());

//uploading to database column as Image Type
SqlCommand cmd=new SqlCommand();
cmd.Connection=conn;
cmd.CommandText ="update table1 set imagecol=@imagecol where id='123'";
cmd.Parameters.Add (new SqlParameter("@imagecol",SqlDbType.Image) ).Value=
(new ASCIIEncoding()).GetBytes(strImageName.ToString());
int result=cmd.ExecuteNonQuery();
Response.Write("Affected Rows: " + res);
cmd.Dispose();

Note: SQL Datatype "Image" and few others are getting obselete / repalced in latter versions...Microsoft Recommends not to use these datatypes in your development going further.
Hope this helps someone....

Monday, March 17, 2008

ASP.Net applications and Services are Locked down in IIS


Incase you get the error while loading projects in VS.

try following;
1. Open IIS.
2. Expand local computer.
3. Click "Web Service Extensions"
4. Select appropriate web service extension. In this case ASP.NET vX.X
5. Click the button named "Allow".

This might happen when there is different versions of .Net Framework is installed on the same system.

Reference URL:
http://www.microsoft.com/technet/prodtechnol/WindowsServer2003/Library/IIS/44f16c37-f727-4244-9813-2289e13dadba.mspx?mfr=true

Saturday, March 15, 2008

SQL2000 Notification Service-How to..

Coming up shortly...

How to create a white space in the XML Text node

XmlDocument doc = new XmlDocument();
XmlNode nNode = doc.CreateElement("Name");
nNode.AppendChild(doc.CreateTextNode(Convert.ToChar(160).ToString()));

Output would be something like: <Name> </Name> instead of </Name>
.....Hope this helps someone!