Search This Blog

Monday, August 31, 2009

Enable sqldependency in SQLServer 2008

aspnet_regsql.exe -S server -U user -P password -d database -ed

Thursday, August 20, 2009

how to view saved username in computer.

I was accessing other's pc and he/she has put login aunthentication for security purpose.
So instead of writing again and again username nd password I have save the password.
To view or remove it do the following steps :
1) Go to run.
2) Type rundll32.exe keymgr.dll, KRShowKeyMgr.
You will get the pc name which pc's password you have saved. To remove it click on remove.

Tuesday, August 18, 2009

import excel sheet to database

open sqlserver nd right click on db nd click import data link nd do the further process to import ur excel sheet to database.
ur data will be imported from the excel sheet to database.

Wednesday, August 12, 2009

Procedure to Delete data of database table

Create Procedure dbo.sp_EmptyAllTables (@ResetIdentity Bit)

As

Begin

Declare @SQL VarChar(500)

Declare @TableName VarChar(255)

Declare @ConstraintName VarChar(500)

Declare curAllForeignKeys SCROLL CurSor For Select Table_Name,Constraint_Name From Information_Schema.Table_Constraints Where Constraint_Type='FOREIGN KEY'

Open curAllForeignKeys

Fetch Next From curAllForeignKeys INTO @TableName,@ConstraintName

While @@FETCH_STATUS=0

Begin

Set @SQL = 'ALTER TABLE ' + @TableName + ' NOCHECK CONSTRAINT ' + @ConstraintName

Execute(@SQL)

Fetch Next From curAllForeignKeys INTO @TableName,@ConstraintName

End

Declare curAllTables Cursor For Select Table_Name From Information_Schema.Tables Where TABLE_TYPE='BASE TABLE'

Open curAllTables

Fetch Next From curAllTables INTO @TableName

While @@FETCH_STATUS=0

Begin

Set @SQL = 'DELETE FROM ' + @TableName

If @ResetIdentity = 1 AND OBJECTPROPERTY (OBJECT_ID(@TableName),'TableHasIdentity')=1

Set @SQL = @SQL + '; DBCC CHECKIDENT(''' + @TableName + ''',RESEED,0)'

Execute(@SQL)

Fetch Next From curAllTables INTO @TableName

End

Fetch First From curAllForeignKeys INTO @TableName,@ConstraintName

While @@FETCH_STATUS=0

Begin

Set @SQL = 'ALTER TABLE ' + @TableName + ' CHECK CONSTRAINT ' + @ConstraintName

Execute(@SQL)

Fetch Next From curAllForeignKeys INTO @TableName,@ConstraintName

End

Close curAllTables

Deallocate curAllTables

Close curAllForeignKeys

Deallocate curAllForeignKeys

End

Friday, June 19, 2009

Assembly Error

Error 4 The type 'ASP.aspx_controls_maintop_ascx' exists in both 'c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\online_store\7e5e2cc2\6d0e9d9d\App_Web_iv00njwa.dll' and 'c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\online_store\7e5e2cc2\6d0e9d9d\App_Web_ndsosjuw.dll' D:\Projects\Online_Store\aspx\Confirm.aspx

If you get error like this that 2 assemblies exists in same path then go to the specified path 
c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\
and delete ur project.
Because this is all temporary files and restart ur visual studio.

How to give image url at runtime in any databound controls of asp.net

Take a image tag in ur databound control like gridview,datalist.
If you take asp image tag then set path like bellow
ImageURL = ImageTest(DataBinder.Eval(Container.DataItem, "sLogo") in asp tags.

Here ImageTest is a function in which you can give your imageurl. For example view the following :- 
 protected object ImageTest(object s)
    {
      object path = "~/aspx/productimages/" + Session["Member"] + "\\logo\\" + s;
      return path;
    }

set ur image url in path object variable.

Thank you

Wednesday, June 17, 2009

SQL Tool Belt

Now you can compare your database , copy or get documentation in which you will be able to get your store procedures, tables, views and many more things.

just refer the following sites : -

https://www.red-gate.com/dynamic/downloads/downloadform.aspx?downloadid=831500&password=FUVUDTYYQB&step=3

Tuesday, June 16, 2009

Modify XML Data at runtime

view the following link this will help you.

http://support.microsoft.com/kb/317666
Also refer this : -

 protected void fillXml()
    {
        DataSet dsbanner = new DataSet();
        dsbanner = bsadv.getBannerStore();
        string s = Server.MapPath("../aspx/aspxBanner.xml");
        dsbanner.WriteXml(s);
        xml();      
    }
    public void xml()
    {
        try
        {
            // Create an XML document instance, and load XML data.
            XmlDocument doc = new XmlDocument();
            string s = Server.MapPath("~/aspx/aspxBanner.xml");
            doc.Load(s);
            XmlNode nodelist = doc.DocumentElement;
            foreach (XmlNode node in nodelist.ChildNodes)
            {
                foreach(XmlNode node1 in node.ChildNodes)
                {
                    if(node1.Name == "sBannerImageName")
                        node1.InnerText = "../admin/banner/" + node1.InnerText;
                }
            }
            doc.PreserveWhitespace = true;
            XmlTextWriter wrtr = new XmlTextWriter(s, Encoding.Unicode);
            doc.WriteTo(wrtr);
            wrtr.Close();
        }
        catch (Exception ee)
        {
        }
   }

Metadata Error

Metadata file 'C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\myweb\8c7cf79c\37f396b\App_Web_4a6-li_x.dll' could not be found  

If you got error like this then go to this perticular directory and search the file without extension and you will get the same file with extension .delete change it and rename it with .dll.
Your problem will be solved.

Monday, May 25, 2009

Compress Javascript for your code

You can compress your javascipt which resize your javascript code and does less load on server when page is loaded.

For more information refer this link : -


Debugg the store procedure in sql server 2005

1. Find the .exe file under the directory, C:\Program Files\Microsoft SQL Server\90\Shared\1033\rdbgsetup.exe or similar path where the SQL Server was installed. The file rdbgsetup.exe stands for 'RemoteDeBuGsetup'. Look for the emphasis on letters. The filename reads rdbgsetup because, we are going to debug a stored procedures of a database available in some remote physical server. Either we need to sit at the server and debug them or we should be in a position to debug the stored procedure remotely. This action should be performed on the physical server where SQL Server 2005 was installed. 

2. The user who debugs the stored procedure should be a member of SQL Server's fixed Server role, SysAdmin. 

As a DBA, I may need to grant this privilege to the user who is in need of debugging a stored procedure. When I do that, I should trust the user so that he/she will not mess-up anything on the Server. Ok, I believe my users are trust worthy and I issue the following T-SQL command to assigning a fixer server role, SysAdmin. 

The command to do so is as follows


EXEC master..sp_addsrvrolemember @loginame = N'<YourLoginName either SQL Server Authentication or Windows Authentication>', @rolename = N'sysadmin' 

This can however be accomplished with SQL Server Management Studio's IDE. Perhaps, I prefer using T-SQL commands. 

Note: The parameters to the stored procedure, sp_addsrvrolemember are of type, Nvarchar and it stands for (National Variable Character), which usually holds Unicode characters. 

Now, we are all set for debugging stored procedures. 

Process to Debug a stored procedure


1. Open the Microsoft Visual Studio 2005 IDE. 

2. Select Server Explorer option from the View Menu as follows: 

 

3. From the Data Connections node, right click and select, 'Add connection'. Fill in the details to connect to the intended SQL Server and the database using the login who has a fixed server role, SysAdmin. Click on Test connection. Once the connection succeeds, the overall screen should look like the following. 

 

4. Expand the data connection just added, and navigate to the Stored Procedures node. 

5. Expand the Stored Procedures node and select the intended SP to be debugged. 

6. Right click and select open to view the source code of the selected stored procedure. 

7. Place a break point on the intended line of code where debugging needs to be started its usually the way .NET Developers perform. 

8. After performing the above steps the screen shot should look like the following. 

9. After performing the above steps the screen shot should like the following: 

 

10. Right click on the stored procedure from the 'Server Explorer' and select 'Step-Into Stored Procedure' as shown below. 

 

11. This action brings up the following screen shot. 

 

12. Enter the needful values and click Ok. The next shot will be the following. 

 

13. From here on, its usual .NET debugging stuff. Use Step-Into and Step-Over and Step-out from the shortcuts menu or pressing F11,F10, Shift+F11 

Wasn't that very simple. It made the life of DB developers much more comfortable. Had it not been available with SQL Server 2005 and VS 2005 IDE it would have been a nightmare to debug stored procedures remotely/locally. 

Happy Development and concentrated debugging.