How to use Aspnet_regsql to create Application Services Database?

by Victor 8. June 2010 23:11

Aspnet_regsql.exe is a tool for installing the SQL Server database used by the SQL Server providers. The file is located in the "c:\WINDOWS\Microsoft.NET\Framework\versionNumber folder" on your web server. There are too ways to run this tool: the wizard form and the command line.

1. To run this using wizard is very simple. 
Step 1: Run the aspnet_regsql.exe from your command line without any arguments. Then the wizard windows form will appear.  Click the Next Button.

Step 1

Step 2: Choose what you want to do with the sql database. In this example we want to create a new application services database. So we just select the first option then Click the Next Button.

Step 2

Step 3: Enter your sql server name, authentication method and the database name. If the database has already existed, you can select the dropdownlist. If the database is new, you only need to type in the new database name in the dropdownlist. Click the Next Button.

Step 3

Step 4: Confirm the information then then Click the Next Button.

Step 4

Step 5: Done. 

Step 5

After that your database should be created. And it should look likes this.

sql server view

2. Also you can run the tool as a command-line utility. The options for the command are

Option Description
-? Prints Aspnet_regsql.exe tool Help text in the command window.
-W Runs the tool in wizard mode. This is the default if no command line arguments are specified.
-C connection string The connection string to the computer running SQL Server where the database will be installed, or is already installed. This option is not necessary if you only specify the server (-S) and login (-U and -P, or -E) information.
-S server The name of the computer running SQL Server where the database will be installed, or is already installed. The server name can also include an instance name, such as .\INSTANCENAME.
-U login id The SQL Server user id to log in with. This option also requires the password (-P) option. This option is not necessary if you are authenticating using Windows credentials (-E).
-P password The SQL Server password to log in with. This option also requires the login id (-U) option. This option is not necessary if authenticating using Windows credentials (-E).
-E Authenticates using the Windows credentials of the currently logged-in user.
-d database The name of the database to create or modify. If the database is not specified, the default database name of "aspnetdb" is used.
-sqlexportonly filename Generates a SQL script file that can be used to add or remove the specified features. The specified actions are not performed.
-A all|m|r|p|c|w Adds support for one or more features. The following identifiers are used for ASP.NET features.
all All features
m Membership
r Role management
p Profile
c Web Parts personalization
w Web events
Feature identifiers can be specified together or separately, as shown in the following examples. aspnet_regsql.exe -E -S localhost -A mp aspnet_regsql.exe -E -S localhost -A m -A p
-R all|m|r|p|c|w Removes support for one or more features. The identifiers are the same for the add option.. Here is some examples. aspnet_regsql.exe -E -S localhost -R mp aspnet_regsql.exe -E -S localhost -R m -R p
-Q Runs the tool in quiet mode and does not confirm before removing a feature.

So if you want to add database elements for membership and role management in database test on localhost using the current windows user. The command should be:

aspnet_regsql.exe -E -S localhost -d test -A mr

Tags: ,

Programming

Copy & Paste functions does not work in Visual Studio 2010

by Victor 4. May 2010 23:33

The new Visual Studio 2010 is cool. It has lots of existing new features. But I have found out my cut and paste function doesn't work properly. Then I found this post. Someone in Microsoft said: " There is a known issue with symptoms like the ones you describe - text will occasionally fail to paste.  Although it's not exclusive to remote desktop, that does make it significantly more likely.  The underlying issue is being tracked by an internally-filed bug and we're working on a fix.  For now, the best course of action is just to try copy/paste again; changing settings shouldn't affect this bug......". This is unbelievable. Every developer must know how important cut/paste is. Then in Visual Studio 2010 - the one of the most important product release this year, this basic function doesn't work. Totally Unbelievable!!!

Tags:

Programming

Named argument in C# 4.0

by Victor 4. May 2010 23:16

Named argument is a new feature in C# 4.0. Using this feature you do not need to remember or to look up the order of parameters in the parameter lists of called methods. The parameter for each argument can be specified by parameter name. In this case documentation become really important. 
For example, a simple function that return the sum of two parameters can be called in the standard way by sending arguments for param1 and param2 by position, in the order defined by the function.

SimpleFunction(100, 50); 

If you do not remember the order of the parameters but you do know their names, you can send the arguments in either order, weight first or height first.

SimpleFunction(param1: 100, param1: 50);
SimpleFunction(param2: 50, param1: 100);

Named arguments also improve the readability of your code by identifying what each argument represents. But it doesn't mean your documentation become unnecessary. 
Also A named argument can follow positional arguments (which are not specified by parameter name), like:

SimpleFunction(100, param2: 50);

In this case you cannot change the order of the arguments. However, a positional argument cannot follow a named argument. Even you follow the current argument order.  The following statement causes a compile time error (Named argument specifications must appear after all fixed arguments have been specified).

SimpleFunction(param1 : 100, 50);

Full Code Example

namespace ConsoleApplication1
{
  class Program
  {

    static void Main(string[] args)

    {
      Console.WriteLine(SimpleFunction(100, 50));//Successful
      Console.WriteLine(SimpleFunction(param1: 100, param2: 50));//Successful
      Console.WriteLine(SimpleFunction(param2: 50, param1: 100));//Successful
      Console.WriteLine(SimpleFunction(100, param2: 50));//Successful
      Console.WriteLine(SimpleFunction(param1: 100, 50));//Error
    }

    static int SimpleFunction(int param1, int param2)
    {
      return param1 + param2;
    }
  }
}


Tags:

Programming

How to do bulk deletion in SharePoint?

by Victor 20. April 2010 16:05

How to bulk delete in SharePoint?

The normal way to delete file programmatically in SharePoint is using the SharePoint API. The code looks like:

foreach(SPList myList in myWeb)
{
  foreach( SPListItem item in myList )
  {
    item.Delete();
  }
}

This works fine for document libraries contain small amount of data. It will be extremely slow when you have document libraries contain millions of records. In this case, you will need bulk deletion.

In order to use bulk deletion you need to know the CAML and how to use SPWeb.ProcessBatchData() methods.
There is the example.

private static String BuildBatchDeleteCommand( SPList list, SPListItemCollection coll )
{
  StringBuilder sbDelete = new StringBuilder();
  sbDelete.Append( "<?xml version=\"1.0\" encoding=\"UTF-8\"?><Batch>" );
 
  // We prepare a String.Format with a String.Format, this is why we have a {{0}}
  string command = String.Format( "<Method><SetList Scope=\"Request\">{0}</SetList><SetVar Name=\"ID\">{{0}}</SetVar><SetVar Name=\"Cmd\">Delete</SetVar><SetVar Name=\"owsfileref\">{{1}}</SetVar></Method>", list.ID );
  foreach ( SPListItem item in coll )
  {
    sbDelete.Append( string.Format( command, item.ID.ToString(), item.File.ServerRelativeUrl ) );
  }
  sbDelete.Append( "</Batch>" );
  return sbDelete.ToString();
}

// While there's something left
while ( list.ItemCount > 0 )
{
  // We get everything but we limit the result to 100 rows
  SPQuery q = new SPQuery();
  q.RowLimit = 100;
 
  // We get the results
  SPListItemCollection coll = list.GetItems( q );
 
  // We process a CAML batch
  String batch = BuildBatchDeleteCommand( list, coll );
 
  // We execute it
  web.ProcessBatchData( batch );
 
  list.Update();
}

BTW the methods returns a String, if your code doesn’t work, it would return you an error code. If everything is fine, it just return "0x00000000".

Tags:

Programming | Sharepoint

What is the difference between get, post and put method in HTTP?

by Victor 23. December 2009 15:31

GET Method:

  1. All the name value pairs are submitted as a query string in URL.
  2. It's not secured as it is visible in plain text format in the Location bar of the web browser.
  3. As the data transfers through address bar (URL) there are some restrictions in using space, some characters like ampersand (&) etc in the GET method of posting data. We have to take special care for encoding data if such special characters are present.
  4. Length of the string is restricted.
  5. If method is not mentioned in the Form tag, this is the default method used.
  6. If get method is used and if the page is refreshed it would not prompt before the request is submitted again.
  7. One can store the name value pairs as bookmark and directly be used while sharing with others - example search results.
  8. Data is always submitted in the form of text
  9. If the response of the page is always same for the posted query then use GET example database searches

 

POST Method:

  1. All the name value pairs are submitted in the Message Body of the request.
  2. Length of the string (amount of data submitted) is not restricted.
  3. Post Method is secured because Name-Value pairs cannot be seen in location bar of the web browser.
  4. If post method is used and if the page is refreshed it would prompt before the request is resubmitted.
  5. If the service associated with the processing of a form has side effects (for example, modification of a database or subscription to a service), the method should be POST.
  6. Data is submitted in the form as specified in enctype attribute of form tag and thus files can be used in FileUpload input box.

 

PUT Method:

  1. A put allows you to "put" (upload) a resource (file) on to a webserver so that it be found under a specified URI. DELETE allows you to delete a resource (file). These are both additions to HTTP/1.1 and are not usually used. HEAD returns just the HTTP headers for a resource. TRACE and OPTIONS are also HTTP/1.1 additions and also rarely used.

Tags: ,

Programming

Questions about "vshost" files

by Victor 15. September 2009 05:38

Here are some common questions about the vshost file:

What is vshost.exe file and what is that for?

Vshost file is the hosting process file. Microsoft introduced this from Visual Studio 2005. It has three main purposes.
1. Improve the performance for debugging. 
Managed code need to run inside application domains which provide isolation, unloading, and security boundaries for executing managed code. But it takes some time to create an AppDomain and initialize the debugger along with it. When your application end, the AppDomain and debug state will get lost. When you debug your code, you need to do it over and over again. It becomes not ideal at all. So the job of the hosting process is to improve performance by handling creation of the AppDomain and the initialization of the debugger at the background before you start debugging and keep the state around between runs of your application.
2. Allow partial trust debugging.
From Visual Studio 2005, you have the ability to debug applications in partial trust with permission settings as defined on the new Security page. When you deploy a partial trust application, it runs in a limited security context automatically. However, simulating a partial trust environment within Visual Studio under the debugger requires special initialization of the AppDomain, which is handled by the hosting process.
3.Allow design time expression evaluation.
The hosting process gives you the ability to test code in your application from the immediate window, without actually having to run your application. The hosting process is also used to execute your code under design time expression evaluation.

Why it is in the "Bin" folder?

When your application is run within the hosting process "vshost" is the top level executing assembly in the AppDomain, not your application. Therefore assemblies, config files, and manifest files cannot be properly loaded in all scenarios unless the "vshost" files are in the same folder with all of the other files.

Can I remove the "vshost" file from the release build?

Yes, you can. The *.vshost.exe file are only needed by visual studio IDE. They do not have any other usage.

How to stop generating "vshost" files?

It very simple to stop generating "vshost" files. In the project's property page, you need to change the configuration to be release.  And in the enable debuggers section untick the option "Enable the Visual Studio hosting process".


 

Tags:

Technology | Programming

Calendar

<<  February 2012  >>
MoTuWeThFrSaSu
303112345
6789101112
13141516171819
20212223242526
2728291234
567891011

View posts in large calendar

Month List