Skip to main content

Posts

Showing posts from July, 2011

MVC 3 Reload PartialView by using jQuery and AJAX

Sometimes it`s easier to reaload only part of the website witout reloading whole page. Thanks to AJAX technology such aproach is possible and easy to code. Let`s begin. Firstly we need to configure our environment so we must have a Visual Studio with MVC 3  Razor isntalled on it. Razor can be obtained from here . After installation process completed , the second step is to set up a new WebStie project (Picture 1.) Picture 1. After you confirm Your project type choise, next window starts. On it You should select the second web project type (with Forms autentication method)  and than choose RAZOR form dropdown (Picture 2.). Picture 2. Now You new web solution contains several folders and files by default. Their description is not a point of this article so allow myself to continue. Next step is to create a simple model for our PartialView. As an example I  created a simple _UserModel.cs in Models folder. The source code for this model is:  public class _UserModel     {  

Read from MS SQL BLOB column

In SQL SERVER 2005 the most common data type for storing BLOBs was an IMAGE  datatype. When SQL Server 2008 and later SQL SERVER  2008 R2 occured the image datatypes coexists with several new and recomended by Mictosoft BLOB datatypes such varbinary(MAX). Let`s have a look: varbinary(max) /binary(n)  variables store variable-length binary data of approximately n bytes, may store a maximum of 2 gigabytes. image variables store up to 2 gigabytes of data and are commonly used to store any type of data file (not just images). But when you`re designing a new database structure be patient and choose the newest one type according to the Microsoft note: "ntext, text, and image data types will be removed in a future version of Microsoft SQL Server. Avoid using these data types in new development work, and plan to modify applications that currently use them. Use nvarchar(max), varchar(max), and varbinary(max) instead. Fixed and variable-length data types for storing large non-Unico

Create a new databse in stored procedure (SQL SERVER 2008 R2)

Sometimes one of the business requirements of the system is to create a new databse at the runtime. When You using SQL Server this operation can be done easy and quick. The stored procedure below takes two arguments. First 'DbName ' sets a name for new database and the second one gathers information about success of the operation as true or false. Note that second argument is output type which means that in C# code you can get information about create new database. Now its time for some magic. After creating a new DB there is no object inside. But You don`t have to move all of structure to new DB each time you create a new one. In SQL Server one of the four database names 'model'. When you move all of Your buissnes logic (tables, views, stored procedures and even data) to it, all the structured will be move to new DB when it`s creating. Looks great, but remeber that if you have some PK on the table with data in model DB during cration of new DB PK values will be r