Tuesday, November 30, 2004

upload local image file from client into database

1.
this is the easiest way to get  a file from ur Harddisk in

a web form.




File:


"

2.
http://www.aspfree.com/c/a/ASP.NET/Uploading-Images-to-a-Database--C---Part-I/

Friday, November 12, 2004

Wednesday, November 10, 2004

[ASP] A superb meun server control

This is a menu server control created by

Scott Mitchell
4GuysFromRolla.com

November 2003

very useful. I will try it.

[SQL] use Information Schema Views

In SQL Server, we can use information schema Views to get meta information about tables.
Such as, to get the number of columns:

SELECT count(column_name)
FROM Information_Schema.Columns
WHERE Table_Name = 'Projects'

Tuesday, November 09, 2004

[SQL]Use variable in FROM clause in SQL Server

Problem: Try to implement:
Declare @tbName text
SELECT * FROM @tbName;

That will cause error. The soluthion is using dynamic SQL:

EXEC ( 'SELECT * FROM ' + ' " ' + @tbName + ' " ')

Put double quote to prevent the table name contains space.

Stored Procedure and SQL query:

CREATE PROCEDURE titles_cursor @titles_cursor CURSOR VARYING OUTPUT
AS
SET @titles_cursor = CURSOR
FORWARD_ONLY STATIC FOR
SELECT name
FROM sysobjects
WHERE xtype = 'U'
ORDER BY name

OPEN @titles_cursor
GO

--------------
use "Capital Improvement Projects"
GO

DECLARE @MyCursor CURSOR

EXEC titles_cursor @titles_cursor = @myCursor OUTPUT
DECLARE @tbName VARCHAR(200)
FETCH NEXT FROM @MyCursor INTO @tbName

WHILE (@@FETCH_STATUS = 0)
BEGIN
PRINT 'SELECT * AS '+'"'+@tbName+'" '+' FROM ' + @tbName
EXECUTE ('SELECT COUNT(*) AS '+'"' + @tbName+ '" ' + ' FROM ' + '"' + @tbName + '"')
FETCH NEXT FROM @MyCursor INTO @tbName
END
CLOSE @MyCursor
DEALLOCATE @MyCursor

GO