Thursday, December 18, 2008

Integration of Aspnet membership DB with your own DataBase

Open Command Promt and change the directory to your .net 2 framework directory e.g. C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727. If you use VS 2008, still you have to go to .net 2 directory not 3.5. Then run the following command -

aspnet_regsql -A mr -C "Data Source=localhost;Initial Catalog=targetDB;Integrated Security=true"

Here the assumption is that the target application database will be targetDB.

After executing this command you will find application database will contain 6 additional tables -

aspnet_Applications,
aspnet_Membership,
aspnet_Roles,
aspnet_SchemaVersions,
aspnet_Users and
aspnet_UsersInRoles

These tables will serve aspnet built-in user & role management. Then in config file add the following connection string -

add name="SqlServices" connectionstring="Data Source=localhost;Integrated Security=SSPI;Initial Catalog=targetDB;

If you don't name the connection string as "SqlServices", you have to configure the membership in config file by yourself.

Wednesday, December 3, 2008

XML data type manipulation in sql server

A very useful link regarding this http://www.15seconds.com/issue/050803.htm.

If your database contains XML data but the field type is text or varchar, then you need to convert or cast the data to XML then manipulate query ,value & exist method described in the above link.

For cast & convert, see http://msdn.microsoft.com/en-us/library/ms187928.aspx