Monday, September 7, 2009

SQL Server Case sencitive Query

Just put COLLATE Latin1_General_CS_AS allong with WHERE condition

ex:

SELECT * from tbl_User
WHERE State COLLATE Latin1_General_CS_AS = 'nc'

Wednesday, August 26, 2009

calling webservice from javascript with parameters

below is a simple javascript to tell you how to call web service with parameter
It will give you state and City for a zipcode you given
please assume there is 3 text boxes txtZip, txtState and txtCity
<script type="text/javascript">
var WebReq = null;
function findZip() {

//create dom
if (window.XMLHttpRequest)
WebReq = new XMLHttpRequest();
else if (window.ActiveXObject) {
if (new ActiveXObject("Microsoft.XMLHTTP"))
WebReq = new ActiveXObject("Microsoft.XMLHTTP");
else
WebReq = new ActiveXObject("Msxml2.XMLHTTP");
}

//url of webservice. see last, which is the name of our method to call
var url = "http://localhost:2508/MyProject/MyWebService/Service1.asmx/getCityState";
WebReq.open("post", url, true);
WebReq.setRequestHeader("Host",http://myproject/);
WebReq.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
WebReq.setRequestHeader("Content-Length","100");

//now mention method name (here is Result, check below i declared the method Result() ), ie after sending request , it will call this method to execute web response
WebReq.onreadystatechange = Result;
//taking zipcode from txtZipCode
var vZipCode = document.getElementById('');
//Adding Parameter ZipCode
WebReq.send("ZipCode=" + vZipCode.value);
}
function Result()
{
if (WebReq.readyState == 4 && WebReq.status == 200)
{
var dsRoot=WebReq.responseXML;
var City = dsRoot.getElementsByTagName('City')[0].firstChild.nodeValue;
var State = dsRoot.getElementsByTagName('State')[0].firstChild.nodeValue;
//Setting New value to city and State
var vCity = document.getElementById('');
var vState = document.getElementById('');
vCity.value = City;
vState.value= State;
}
}

Thursday, August 20, 2009

InnerText problem in firefox

its tue that innerText property does not support firefox, but it will work in IE. This is one of the issues facing on web developers. Here is my solution

below example will store 100 in label lblPremAmt.

firefox support textContent property which is equivalent to innerText in IE.

var vlblPremAmt = document.getElementById("<%= lblPremAmt.ClientID %>");

if(document.all)
{
vlblPremAmt.innerText = 100;
}
else
{
vlblPremAmt.textContent = 100;
}

Monday, August 3, 2009

call and execute a method using HttpWebRequest

Here is test code will call and execute a method in some server and retrive xml output.


string Qstring = "name=Alex&age=20";
string url = "https://mywebserver.com/websites.exe";
string data = Qstring; HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(url);

request.Method = WebRequestMethods.Http.Post;
request.ContentLength = data.Length;
request.ContentType = "application/x-www-form-urlencoded";

StreamWriter writer = new StreamWriter(request.GetRequestStream());
writer.Write(data);
writer.Close();

HttpWebResponse response = (HttpWebResponse)request.GetResponse();
StreamReader reader = new StreamReader(response.GetResponseStream());

strMVRXML = reader.ReadToEnd(); response.Close();
System.Xml.XmlDocument xDoc = new System.Xml.XmlDocument();
xDoc.LoadXml(strXML);

Tuesday, May 12, 2009

how to get error message from error no in SQL server

SELECT * FROM master.dbo.sysmessages
WHERE error = 8115 AND msglangid = 1033

Tuesday, March 24, 2009

Asp.net Querystring Encrypt

ur query string in url address will be encrypted but u can access querystring using
Request.QueryString["<QueryStringName>"].
no need to add any xtra code, just follow below 2 steps

1. Download .cs file from http://blog.madskristensen.dk/post/HttpModule-for-query-string-encryption.aspx

2. modify web config file


<httpModules>
<add type="QueryStringModule" name="QueryStringModule" />
</httpModules>

Friday, March 20, 2009

Delete Key Fro registry

RegistryKey key = Registry.CurrentUser;
key.DeleteSubKey("Software\\Rosh");

//Removing From startup
Registry.LocalMachine.OpenSubKey ("SOFTWARE\ Microsoft\Windows\ CurrentVersion\ Run", True).DeleteValue(Application.ProductName)

How to run an application next to installation finish in Visual studio

In your setup & deployment project

Step 1: Create a vbs file with following command

Set WshShell = CreateObject("WScript.Shell")
WshShell.Run """" & Property("CustomActionData") & """",5,False
Set WshShell = Nothing

Step 2: Open file system (View-->Editor-->File System) window

Create a new folder (suppose, Launch) and add above vbs file into the folder.
Also add the .exe file, which should run after setup application finish.

Step 3: Open Custom Action (ViewEditorCustom Actions) window
There u can see 4 tree nodes
1. Install
2. Commit
3. Rollback
4. Uninstall
Step 4: Right click on Commit Node and select Add Custom Action

Step 5: select our vbs file from file system.
Now in Commit folder contains a vbs file

Step 6: Select the vbs file and change CustomActionData property as

[TARGETDIR]YourApp.exe

Where YourApp.exe is the name of the file you want to execute after installation
[Note : yourApp.exe and .vbs file should contain in the same folder]

For Execute an application after uninstall process

Do the same step in Uninstall folder

Tuesday, March 10, 2009

Remove quotes from string C#

System.Text.RegularExpressions.Regex.Replace(your Variable, expression, replace Character/string);

below ex remove quotes from input string

string str=@"ha\"llo\"
System.Text.RegularExpressions.Regex.Replace(str, @"""|\\", "");

Tuesday, February 3, 2009

full text search MS SQL server

step 1. Create full text index on table

step 2. type sql Command

Select * from Where Freetext( , searchText)

ex:
select * from Supplier where freetext(Suppliername,'baxi combi')

will return all rows where supplier name contain baxi or combi.

Monday, February 2, 2009

IIS Version

to know iis version just type

http://localhost/IISHelp