Vincent Leung .NET Tech Clips

The latest tech clips from the .NET community

Lucene tutorial

November 3, 2009 Posted by Vincent Leung | Database, LINQ, Tools | | No Comments Yet

Lucene.Net and Azure

 


Azure Library for Lucene.Net

“Lucene works on top of an abstract store object called Directory. There are several Directory objects, including FSDirectory, for file systems, and RAMDirectory, for in-memory store. Azure Library for Lucene.Net implements a smart blob-storage Directory object called AzureDirectory which enables the use of Lucene.NET on top of Azure Blob Storage. AzureDirectory automatically creates a local cache of blobs and intelligently auto-uploads them on the fly.

September 17, 2009 Posted by Vincent Leung | Azure, Database, Tools | | No Comments Yet

Introduction to NHibernate – Dimecasts.Net

December 13, 2008 Posted by Vincent Leung | Database | | No Comments Yet

Displaying the Sizes of Your SQL Server’s Database’s Tables

 

Determining the Space Used by a Database or a particular Table
SQL Server has a handy little system stored procedure named sp_spaceused that will return the space used by a database or by a particular table. To determine the size used by the database, simply run:

EXEC sp_spaceused [table]

Returning the Space Used for All Tables

The sp_MSforeachtable stored procedure is one of many undocumented stored procedures tucked away in the depths of SQL Server. A list of these handy stored procedures can be found at SQL Server 2000 Useful Undocumented Stored Procedures. In short, you can use sp_MSforeachtable like so:

EXEC sp_MSforeachtable @command1="command to run"

In the command to run put a ? where you want the table name to be inserted. For example, to run the sp_spaceused stored procedure for each table in the database, we’d use:

EXEC sp_MSforeachtable @command1="EXEC sp_spaceused '?'"

This will execute EXEC sp_spaceused 'TableName' for each user table in the database.

Combining Multiple Result Sets Into a Single Result Set Using Temporary Tables

CREATE PROCEDURE dbo.TableSpaceUsed
AS

-- Create the temporary table...
CREATE TABLE #tblResults
(
   [name]   nvarchar(50),
   [rows]   int,
   [reserved]   varchar(18),
   [reserved_int]   int default(0),
   [data]   varchar(18),
   [data_int]   int default(0),
   [index_size]   varchar(18),
   [index_size_int]   int default(0),
   [unused]   varchar(18),
   [unused_int]   int default(0)
)

-- Populate the temp table...
EXEC sp_MSforeachtable @command1=
         "INSERT INTO #tblResults
           ([name],[rows],[reserved],[data],[index_size],[unused])
          EXEC sp_spaceused '?'"

-- Strip out the " KB" portion from the fields
UPDATE #tblResults SET
   [reserved_int] = CAST(SUBSTRING([reserved], 1,
                             CHARINDEX(' ', [reserved])) AS int),
   [data_int] = CAST(SUBSTRING([data], 1,
                             CHARINDEX(' ', [data])) AS int),
   [index_size_int] = CAST(SUBSTRING([index_size], 1,
                             CHARINDEX(' ', [index_size])) AS int),
   [unused_int] = CAST(SUBSTRING([unused], 1,
                             CHARINDEX(' ', [unused])) AS int)

-- Return the results...
SELECT * FROM #tblResults

This stored procedure will return a single result set. The fields that end in _int are the integer representations of those fields that are returned with KB fields.

image

4GuysFromRolla.com – Displaying the Sizes of Your SQL Server’s Database’s Tables

September 10, 2008 Posted by Vincent Leung | Database | | 1 Comment

SQL Compact 3.5 Tidbits & Gotchas!

 

An article detailing the odd problems and solutions to using SQL Compact 3.5 in desktop applications

1. Installing the designer

2. Creating the dbml O/R Mapping

3. The connection string

4. Private installation at deployment

CodeProject: SQL Compact 3.5 Tidbits & Gotchas!. Free source code and programming help

August 11, 2008 Posted by Vincent Leung | Database, MS SQL Compact | | No Comments Yet

The easiest way to export data from MS SQL Server to a csv or text file

Run the query (SELECT * FROM tablename) to get all the data in Query Analyzer, then copy and paste the results from there into Excel. Then save as csv file type.

MSSQL

June 26, 2008 Posted by Vincent Leung | Database | | No Comments Yet

mysqldump — A Database Backup Program for MySQL

 

There are three general ways to invoke mysqldump:

shell> mysqldump [options] db_name [tables]

shell> mysqldump [options] --databases db_name1 [db_name2 db_name3...]

shell> mysqldump [options] --all-databases

In its simplest form, the mysqldump utility can be used like this:

mysqldump –-user [user name] –-password=[password] [database name] > [dump file]

this will include both the schema and data as well.

If you need only the schema use the -d or --no-data option

e.g. mysqldump -d -u root -pp@ssword mydatabase > mydatabase.sql

Reference: MySQL :: MySQL 5.0 Reference Manual :: 4.5.4 mysqldump — A Database Backup Program

June 26, 2008 Posted by Vincent Leung | MySQL | | No Comments Yet

How do I Recompile the MySQL Library to Run Under the Medium Trust Environment in ASP.NET?

Update: You no longer need that if you use the MySQL Connector/Net 5.2 or later.

  1. Download the source code for the MySQL Connector/Net from www.mysql.com.
  2. Extract the contents of the zip file to a local directory.
  3. Open mysql.csproj project file in Visual Studio.
  4. Open the AssemblyInfo.cs file, and add the following code, in the using block, at the top of the file (if it is not already there):using System.Security;
  5. Add the following code to the assembly section of the file:[assembly: AllowPartiallyTrustedCallers]
  6. Recompile the dll.

You may now reference this dll from other projects. When you decide to publish your project to your hosting server, you need to upload this modified version of the dll to your bin directory.

Via How do I Recompile the MySQL Library to Run Under the Medium Trust Environment? – Help Center—Knowledge Base and FAQ

June 9, 2008 Posted by Vincent Leung | ASP.NET, Database, MySQL | | No Comments Yet

MySQL ASP.NET Tutorial

 

A Step-by-Step Guide To Using MySQL with ASP.NET

 

MySQL 5 C# sample code using ObjectDataSources

June 9, 2008 Posted by Vincent Leung | ASP.NET, Database, MySQL, Uncategorized | | No Comments Yet

MySQL Tutorial from MySQL.com

June 9, 2008 Posted by Vincent Leung | Database, MySQL | | No Comments Yet