Wednesday, December 24, 2008

SQL Server 2005 linking another server in management studio express

If you have two servers A and B. and you want to link Server B in managment studio express within Server A so that you can use queries to get data from a database in the Server B while remaining in Server A.

or if you want to create join queries from data in both the servers. You can use the link server facility of SQL Server.

here is the query you can use to link a new server

EXEC sp_addlinkedserver
@server='linkedsql', --this will be the server name that will be used in queries later onwards
@srvproduct='',
@provider='SQLNCLI', -- this is the product information
@datasrc='ip\servername' -- this is the server information

when you have linked the server and you want to query the server you can use query like

select * from linkedsql.dbname.dbo.tablename

but it will give you this error

Msg 18452, Level 14, State 1, Line 1

Login failed for user ''. The user is not associated with a trusted SQL Server connection

you have to provide the user credentials and the password for the sql server

You can use the following query to create the password and userid for the linked server.

EXEC sp_addlinkedsrvlogin 'linkedsql', 'false', NULL, 'userid', 'password'

You can also use the object explorer->linked server->properties->security-> be made using this security context. then enter the userid and password and click ok

Friday, August 15, 2008

SEO Related Issues in Drupal

For enabling SEO on a website in Drupal you need to address the following issues:
1: You Need to enable Clean URLS on the site if these are not enabled.
2: install nodewords/metatag module of drupal
3: installation of Path module
4: installation of pathauto/config

then you need to configure static paths of the pages like

www.mysite.com/home instead of www.mysite.com/node/1

after doing this

edit each page and add meta tags like description and keywords to each page this will be enabled if you have installed nodewords/metatag.

Now you should install XML-sitemap and configure it so that it creates an XML of your site each time it is updated and send that XML to google yahoo and other search engines for parsing.

now you should install SEO - checklist and configure. This only checks the status of other modules listed above. Currently it is available for Drupal version 5.x and not for 6.x so please install 5.x for it else do not panic because this is not a required module for SEO in Drupal, it just helps a lot in checking the status.

Thursday, May 22, 2008

ASP.NET popup with return values.

Some people have problem creating a page that returns value to master window.

I found this article by Peter A. Bromberg, Ph.D. which is good to create popups with return values.

http://www.eggheadcafe.com/articles/20060117.asp

You can use the registerstartupscript and registerclientscript for many purposes.


string script = "<script language='javascript'>"
script += "alert('Hello');"
script += "</script>"

RegisterStartupScript("StartUp",script)

Monday, April 14, 2008

Remove HTML Tags from string in ASP Classic

function removeHtmlChar(strText)
    l=len(strText)
          for i=1 to l
              ch=mid(strText,i,1)             
x=i             
if(ch="<")then                  
x=i                 
do while(mid(strText,x,1)<>">")
                       
x=x+1 
                  
loop
                  
t=t & " "
             elseif
(ch="&") then
                  
x=i                  do While(mid(strText,x,1)<>";")                       
x=x+1                   loop
                 
t=t & " "             else
                 
t=t &ch              end
if
    i=x
    next
    strText=t
end function

Thursday, March 13, 2008

How to Delete a file from Server (ASP Classic / ASP.NET)

If you are using ASP Classic to delete a file from server you can use the following script:
<%
Dim filepath, strPhysicalPath
filepath = Session("filetodelete")
strPhysicalPath = Server.MapPath("directoryvirtualpath" & filepath)
set oFile = CreateObject("Scripting.FileSystemObject")
oFile.DeleteFile (strPhysicalPath), True
set oFile = nothing
%>

but if you are using ASP.Net You will need the Following Code:
Dim oDir As New DirectoryInfo(path)
Dim oFile As FileInfo
For Each oFile In oDir.GetFiles(SearchPattern)
oFile.Delete()
Next

Tuesday, March 4, 2008

AJAX.net Full page postBack Problem

If you have this line in your web.config file

<xhtmlconformance mode="Legacy"></xhtmlconformance>

Then there will be a postback of whole page. Remove this from your Web.config for AJAX to run.

CSS Hover and I.E. 7

I had a problem with cssHover. it was running fine in I.E.6 but with I.E. 7 it stopped hovering.
here is how to solve the problem.
Read the Article:
http://blogger.xs4all.nl/peterned/archive/2006/10/27/140300.aspx

To sum the Article you can use.

in csshover.htc, near line 34, change this :

if(!/MSIE (5|6)/.test(navigator.userAgent)) return;
to this:

if(!/MSIE (5|6|7)/.test(navigator.userAgent)) return;

Also please update the stylesheet to



<!--[if IE]>
<style type="text/css" media="screen">
body {
behavior: url(csshover.htc); /* call hover behaviour file */
font-size: 100%; /* enable IE to resize em fonts */
}
#menu ul li {
float: left; /* cure IE5.x "whitespace in lists" problem */
width: 100%;
}
#menu ul li a {
height: 1%; /* make links honour display: block; properly */
}
#menu a, #menu h2 {
font: 12px Trebuchet MS;
/* if required use em's for IE as it won't resize pixels */
}
</style>
<![endif]-->