Microsoft Study Bible

December 17, 2009

Linq statement in Asp.net

Filed under: Developer tools and applications — Tags: , , , , — Jackson @ 4:58 am

If it is in desktop, you just need to

_context.Log = Console.Out;

You just input SQL statement in the console .So, what about in Asp.net?

I want to try to use StringWriter. We can use it to replace Console.Out to help us receive the output log, and save the log in StringBuider.

So, construct an auxiliary class

using System;

 using System.Collections.Generic;

 using System.Linq;

 using System.Web;

 using System.IO;

 using System.Text;

 namespace Clowwindy.Models

 {

 public static class LogHelper

 {

 public static StringBuilder Log = new StringBuilder();

 public static TextWriter In = new StringWriter(Log);

 public static string GetAllLog()

 {

 In.Flush();

 return Log.ToString();

 }

 public static void Clean()

 {

 Log = new StringBuilder();

 In = new StringWriter(Log);

 }

 }

 }

 Add another page log.aspx to display the log

 <%@ Page Language=”C#” AutoEventWireup=”true”

 CodeBehind=”Log.aspx.cs” Inherits=”Clowwindy.Log” %>

 <!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN”

 http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd“>

 <html xmlns=”http://www.w3.org/1999/xhtml” >

 <head runat=”server”>

 <title>SQL Log</title>

 </head>

 <body>

 <form id=”form1″ runat=”server”>

 <asp:Button ID=”btn_Clean” runat=”server” Text=”Clear out”

 onclick=”btn_Clean_Click”/>

 <div>

 <asp:Literal ID=”Literal1″ runat=”server”></asp:Literal>

 </div>

 </form>

 </body>

 </html>

 using System;

 using System.Collections.Generic;

 using System.Linq;

 using System.Web;

 using System.Web.UI;

 using System.Web.UI.WebControls;

 using Clowwindy.Models;

 namespace Clowwindy

 {

 public partial class Log : System.Web.UI.Page

 {

 protected void Page_Load(object sender, EventArgs e)

 {

 if (Request.UserHostAddress != “127.0.0.1″)

 {

 Response.End();

 return;

 }

 Literal1.Text = LogHelper.GetAllLog().Replace(”\n”,”\n<br/>”);

 }

 protected void btn_Clean_Click(object sender, EventArgs e)

 {

 LogHelper.Clean();

 Literal1.Text = null;

 }

 }

 }

Finally, in the places where new DataContext is, Add _context.Log = LogHelper.In:

public Repository()

 {

 _context = new TDataContext();

 _context.Log = LogHelper.In;

 }

Open log.aspx, you will see the previous SQL statements.

October 21, 2009

A way to save and read ntext,image in ASP.net.

Filed under: Developer tools and applications — Tags: , , — Jackson @ 5:33 am

Today, I will introduce a way to use stored procedures to save and read the field ntext and image field. In ASP.net, how should we call the stored procedures?

Firstly, create the procedure:

CREATE   PROCEDURE   sp_textcopy   (

 @srvname   varchar   (30),

 @login   varchar   (30),

 @password   varchar   (30),

 @dbname   varchar   (30),

 @tbname   varchar   (30),

 @colname   varchar   (30),

 @filename   varchar   (30),

 @whereclause   varchar   (40),

 @direction   char(1))

 AS

 DECLARE   @exec_str   varchar   (255)

 SELECT   @exec_str   =

 ‘textcopy   /S      +   @srvname   +

    /U      +   @login   +

    /P      +   @password   +

    /D      +   @dbname   +

    /T      +   @tbname   +

    /C      +   @colname   +

    /W   “‘   +   @whereclause   +

 ‘”   /F      +   @filename   +

    /’   +   @direction

 EXEC   master..xp_cmdshell   @exec_str

 

2. And then, create the table and initialize the data.

create   table     tablename (NO   int,image columnname   image)

 go

 insert  tablename   values(1,0x)

 insert   tablename   values(2,0x)

 go

 

3. Read in the data.

sp_textcopy ‘yourservername’,’sa’,'yourpassword’,'libname’,'tablename’,'imagecolumnname’,'c:\image.bmp’,'where NO=1′,’I’ –Attention is NO=1sp_textcopy   ‘yourservername’,’sa’,'yourpassword’,'libname’,'tablename’,'imagecolumnname’,'c:\bb.doc’,'where    NO=2′,’I’   –Attention is   NO=2

 go

 

4. Read out the data into a file:

sp_textcopy ‘yourservername’,’sa’,'yourpassword’,'libname’,'tablename’,'imagecolumnname’,'c:\image.bmp’,'where NO=1′,’I’ –Attention is NO=1sp_textcopy   ‘yourservername’,’sa’,'yourpassword’,'libname’,'tablename’,'imagecolumnname’,'c:\bb.doc’,'where    NO=2′,’I’   –Attention is   NO=2

 go

 

October 7, 2009

August 31, 2009

Visual Web Developer Express vs Visual Studio 2008?

I am currently reading Beginning ASP.NET with C# and it recommended using Visual Web Developer Express(VWD).But ,I have a battery of questions.Could I use Visual Web Developer Express for all the projects I am planning to do in Visual Studio 2008?Can the Free Express edition satisfy my needs?Or, Is there a need to buy Visual Studio even though I have a VWD?Could you tell me What I can do or can not when I just use the Visual Web developer Express 2008?

If you read this ,do you still recommended me to use UWDE,or any reasons ?
However,I was just thinking about what the Express version lacks ,compared with the Visual Studio.

1.Not Extensibile with other add-ons or third party tools.If I use Visual Web Developer 2008 Express Edition ,I can’t install and use Web Application Projects ,CSS Properties Window,HTML/ASP.net Spell Spell Checker, ReSharper etc like the third party tools.
2.Can not add a Class Library project. If you want to add a Class Library project or a Web Controls Library project to the solution,to be surprised ( Class libraries are popular way to sharing business logic code or any other utility code. ),you can not manage it . Because VWD Express 2008 only supports a single type of project: Web site.Also,VWD 2008 SP1 allows Web Application and Class Library Projects in the solution.
3.Lack of Source Code Control,while a good Source Code Control system can provide us with change history ,branches ,merges ,etc.SCC is key for a professional developer in team development.
4. no Accessibility checker.It is indispensible for you to develop Web sites that must be accessible.
5.Lack of the ability for automatic generation of resources for localization.This means that your Web can not be localized in multiple languages.
6.You want to attach debugger to a process in VWD Express ,sorry you can’t.For example,when you need to step through code in existing classic ASP pages in order to understand how it works or you have to maintain classic ASP pages, you need ASP debugging which requires ability to attach debugger to a running process, the Visual Web Developer Express Edition can not help you .
7. No Native code debugging.For example ,some legacy code, especially in classic ASP code may be using COM objects written in C++. Mixed mode debugging is not supported in Express.
8.Not support opening or editing SharePoint Web sites.
So much you can not do ,maybe you will give up the free Express edition.You will find Visual Studio 2008 more favorable.

However,VWD Express 2008 still has its merits.
The obvious advantage of VWD over VS2008 is that it is free and if you can work smart with it given the missing features, it may be the more pragmatic option for you. If those are features that you can’t live without, VS2008 may be a wise investment - you also get all of the features missing from other Express products (Visual Basic 2008, Visual C# 2008, etc).

In addition,Visual Web Developer Express 2008 is a free web tool that allows you to build CSS, HTML ASP.NET, C#, VB, and JavaScript and supports additional frameworks like ASP.NET MVC, AJAX, Silverlight and jQuery.

So,what should I choose ?Or,I can have a cake and eat it too ?

May 20, 2009

About Web Developer Certification for Asp.Net with C#

Filed under: Developer tools and applications — Tags: , — admin @ 10:37 pm

Microsoft Certified Technology Specialist (MCTS), Microsoft Certified Professional Developer (MCPD),

I would like to know which Microsoft Certification Examination should I write.

I am a pure Asp.Net C# professional and  I am looking for Web Developer Certification for Asp.Net with C#

is it Microsoft Certified Technology Specialist (MCTS) ? or  Microsoft Certified Professional Developer (MCPD) ?

So it is both MCTS and MCPD and the exams are 70-536 and 70-528 to get MCTS and you pass 70-457 to get MCPD. 

If you are pure Asp.net then you will like 70-528 and 70-547.

April 23, 2009

.NET Framework 3.5 Enhancements Training Kit

Filed under: Developer tools and applications — Tags: , , — admin @ 9:35 pm

This has been out for a bit, but I was recently reminded about it, so I figured it was worth a post. If you’re looking for a resource to learn about (or share what you know about) some of the cool new enhancements to .NET 3.5 that came out with SP1, you can find a ton of PowerPoint decks, labs, demos, and more in the .NET Framework 3.5 Enhancements Training Kit.
(more…)

Powered by WordPress

Close
E-mail It