Friday, February 26, 2016

Generating Random Numbers in SQL Server Without Collisions


Saturday, September 3, 2011

MVC

Model–view–controller (MVC) is a software architecture, currently considered an architectural pattern used in software engineering. The pattern isolates "domain logic" (the application logic for the user) from the user interface (input and presentation), permitting independent development, testing and maintenance of each (separation of concerns). The Model-View-Controller (MVC) pattern separates the modeling of the domain, the presentation, and the actions based on user input into three separate classes [Burbeck92]: Model. The model manages the behavior and data of the application domain, responds to requests for information about its state (usually from the view), and responds to instructions to change state (usually from the controller). View. The view manages the display of information. Controller. The controller interprets the mouse and keyboard inputs from the user, informing the model and/or the view to change as appropriate.
Figure 1 depicts the structural relationship between the three objects. It is important to note that both the view and the controller depend on the model. However, the model depends on neither the view nor the controller. This is one the key benefits of the separation. This separation allows the model to be built and tested independent of the visual presentation. The separation between view and controller is secondary in many rich-client applications, and, in fact, many user interface frameworks implement the roles as one object. In Web applications, on the other hand, the separation between view (the browser) and controller (the server-side components handling the HTTP request) is very well defined. Model-View-Controller is a fundamental design pattern for the separation of user interface logic from business logic. Unfortunately, the popularity of the pattern has resulted in a number of faulty descriptions. In particular, the term "controller" has been used to mean different things in different contexts. Fortunately, the advent of Web applications has helped resolve some of the ambiguity because the separation between the view and the controller is so apparent.
Courtesy :msdn

MVC Examples:
A Simple E-Commerce Storefront Application
ASP.NET MVC Source Code
Courtesy: ScottGu's Blog

ASP.NET MVC Tutorials
Courtesy: http://www.asp.net

Friday, September 2, 2011

Use .Net created dll in VB6?

There are the steps to follow:

1) Create a class library in VS choose whatever language you want either Vb.NEt or C#
2) Go to to Project Properties->ConfigurationProperties->build, check the Register for Com Interop check box. This creates the COM wrapper for your .NET assembly and hence need not use regasm.
3) Write whatever code you want, expose the classes publicly, expose the properties, functions you want publicly.

Now in your VB project, add the claslibrary.tlb created by the above program.
Now use the classes and functions as you want.

you should not have any problem.

OR

When you deploy a .NET DLL, and you want to use it with COM (such as VB),
you need to register it with "Regasm.exe your_aseembly_file /codebase".
you need to include the /codebase switch when registing assembly in folders
other than GAC.

To use the /codebase switch, the assembly must be strongly-named

Friday, August 26, 2011

Incorrect format of date parameters via datepicker - Reporting Services

Solution:

Add the Culture setting in the ReportViewer.aspx like below:


<%@ Page Language="C#" AutoEventWireup="true" Inherits="Microsoft.ReportingServices.WebServer.ReportViewerPage" Culture="en-AU"%>

Tip:
You can find the page here: C:\program files\microsoft SQL Server\MSQL.3\Reporting Services\ReportServer\Pages

If you want to find the path to the page go to your IIS under Default website select ReportServer or Reports Folder > right click Properties...

Friday, August 19, 2011

"Can't edit module" when running a VB project

When trying to run a VB project users of SourceSafe frequently encounter the error "Can't edit module." This message is not very helpful as it does not indicate precisely where the problem lies.

There are numerous suggestions for how to fix this issue. Those solutions which we have found to be most helpful are listed below in order of most to least helpful:

- Verify that checked-in components do not contain any blank event procedures. The IDE compiler automatically tries to remove any blank procedures when the project is run. If the file is checked-in, it is read-only, so the change cannot take place. Manually remove the blank procedures or check out the affected forms and run the project once to have the compiler automatically remove the blank procedures.

- Save, close, and check-in all files. Save and check-in the project file. Close and re-open VB.

- Delete the .vbw file for the VB project. It will automatically recreate it the next time you open the project.

Wednesday, November 10, 2010

Convert An Image into Byte[]

using System.Drawing.Imaging;

string FileName = "\\NoImage.jpg";
string DocumentPath = Server.MapPath("~/Images");
System.Drawing.Bitmap myBitmap = new System.Drawing.Bitmap(DocumentPath + FileName);
imgByte = GetImageBytes(myBitmap); //Calling the function GetImageBytes()
fileExtn = "jpg";

//Definition for GetImageBytes()

private byte[] GetImageBytes(System.Drawing.Image image)
{
ImageCodecInfo codec = null;
foreach (ImageCodecInfo e in ImageCodecInfo.GetImageEncoders())
{
if (e.MimeType == "image/png")
{
codec = e;
break;
}
}
using (EncoderParameters ep = new EncoderParameters())
{
ep.Param[0] = new EncoderParameter(Encoder.Quality, 100L);
using (MemoryStream ms = new MemoryStream())
{
image.Save(ms, codec, ep);
return ms.ToArray();
}
}
}

Tuesday, August 31, 2010

Page Element Attributes in Asp.Net 2.0 and there uses

In asp.Net 2.0 there are many attributes in the page tag itself. Each attribute has a special meaning to it. These attributes are defined in the page so that we can specify them for specific pages. Most of them are also defined globally so that we do not have define them in the page.

Here is a list of attributes of the Page Tag.

asyncTimeout – This is an optional attribute to define the timeout for the asynchronous handler during asynchronous processing of the page. The default value is 45 sec.

autoeventWireup – This is also an optional attribute that defines if the events in the page are automatically enabled. The default value is true. This means

if we define a Page_load(with same signature) method in the page class, the event will be automatically be attached with page load method.

buffer – defines if there will be response buffereing based on URL resource. The default value is true

Compilationmode – This attribute is defined for the asp.net compiler. It defines the compilation model for the page. The values can be Always (meaning page should be compiled every time), Auto (meaning) compiler should not compile the page if possible and never (meaning that the page should never be compiled).

EnableEventValidation – defines if the page controls will be validated in the postback /callback or not.

EnableSessionState - defines the usages of session in the page. Default value is true. Other possible values are false (session will not be saved) and read only (session values can only be read but not written to).

EnableViewState – As the name suggest the tag specifies if the view state will be enabled for the page.

EnableViewStateMac – checks for the authentication of the viewstate. The check is made to check if the viewstate has been tampered on the client side. The default value is true.

MaintainscrollPositiononPostback - Maintains the position of the scroll during post back. The default value is false.

MasterPageFile – Is used to define the master Page for the page (if any).

MaxPageStateFieldLength – This is another optional attribute which takes and int32 type parameter. The attribute is used to define max length of character for the state field of the page. When set to a positive number, the viewstate of the page is broken into many numbers with a max character provided in the field. If the value is a negative number that the viewstate is kept in one variable only. The default value is -1.

PageBaseType – Takes a string value defining the base type that will be used for the bage. The default is System.Web.UI.Page. The value gets overridden by the value in the inherits attribute in the standalone file.

PageParserFilterType - Specifies the type name of a filter that is used by the ASP.NET parser to determine whether an item is allowed in the page at parse time. The filter must derive from the PageParserFilter class.

smartNavigation – determines if the page is going to use smart navigation for IE browser (5.5+). When set to true, in the browser, Navigational flash is eliminated, scroll position is persisted, Element focus is persisted and the history of the browser only stores the last state of the page. The default value is false.

styleSheetTheme – defines the Theme to be used by the page. The theme defined in the attribute is used before the creation of controls.

Theme - Specifies the theme to be used for the page. The theme is applied after the creation of the control.

userControlbaseType – specifies the base type for controls to be used when the page is standalone.

ValidateRequest – Defines if Asp.Net will validate the request for potential dangerous data. Te default value is true.

ViewStateEncryptionMode – Defines the mode of encryption of the viewstate. The attribute will override any default value provided in the configuration value. Possible values are Always, Auto (Viewstate is only encrypted if a controls request for it) and Never. The default value is Auto.