Tuesday, August 5, 2008

Learn with Implementation ---The WCF Videos on Channel9

1)Web Programming with WCF
You need to Install Silverlight to view this video which is readily available on the
the site

VS2008 Training Kit: Web Programming with WCF


2)You can get the Latest Video alerts from Google in you mailbox setting your search term
at http://www.google.com/alerts?hl=en&gl=

Which is the easiest and efficient way of learning new technology

Tuesday, July 22, 2008

Some Common Obstacles While Implementing WCF

1)Error:Unknown directive ServiceHost in WCF service
Solution:
Reinstall the VS2008 for fixing the error .Confliction in version 2.0.0.0 of Windows Communication Foundation (pre-release) as well as version 3.0.0.0 (rtm)causes this error

2)Sending large amount of Data with WCF service
Solution:1)WCF Message Streaming
If InsufficientMemoryException is thrown when writing to the channel
then you need to stream both request and response data from client and server
respectively..

Some more problems and solutions yet to be added.Comments are welcome from the readers

Thursday, July 17, 2008

Exporting Data From Excel to SqlServer

Following are the ways to export data from excel to sql server
1)With SQLBulkCopy
create file info.xls and create table in respective database named ExcelData
Source code as follows
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
using System.Data.OleDb;
using System.Data.Common;
public partial class ExportFromExcelToSQL : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{


// Connection String to Excel Workbook

string excelConnectionString = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Inetpub\wwwroot\excel\Info.xls;Extended Properties=Excel 8.0";


// Create Connection to Excel Workbook
using (OleDbConnection connection = new OleDbConnection(excelConnectionString))
{
OleDbCommand command = new OleDbCommand("Select ID,Data FROM [Sheet1$]", connection);


connection.Open();

// Create DbDataReader to Data Worksheet
using (DbDataReader dr = command.ExecuteReader())

{

// SQL Server Connection String
string sqlConnectionString = "Data Source=ITCUBE-4M1HVRHY; Initial Catalog=ITC;User ID=cp;Password=cp;";

// Bulk Copy to SQL Server
using (SqlBulkCopy bulkCopy = new SqlBulkCopy(sqlConnectionString))
{
bulkCopy.DestinationTableName = "dbo.ExcelData";
bulkCopy.WriteToServer(dr);
}
}
}




}
}

2)With DTS utility of SQL

Friday, July 4, 2008

Catching Errors in Event Log in root folder

Hello All,

This function helps you write the errors to event.log
which can be called in the catch block of try and catch.

public void CatchError(Exception objErr)

{
//Exception objErr = Server.GetLastError().GetBaseException(); --This is
//to be used in application_error and Page_error events


string err = "Error Caught in try and catch block \n" +
"Error in: " + Request.Url.ToString() +
"\nError Message:" + objErr.Message.ToString() +
"\nStack Trace:" + objErr.StackTrace.ToString() ;
err = err + System.DateTime.Today.ToString() +" " + txtPhoneNumber.Text +"\n";



// EventLog.WriteEntry("SAWeb", err, EventLogEntryType.Error); This s //to be used while writing to event log
//Server.ClearError();
// additional actions...
// TextWriter tw = new StreamWriter("C:/Inetpub/wwwroot/SAWeb/logs/error.log",true);

TextWriter tw = new StreamWriter(Request.PhysicalApplicationPath.ToString() + "logs\\error.log", true);
// write a line of text to the file
tw.WriteLine(err);

// close the stream
tw.Close();



}

Friday, June 20, 2008

Helpful Tips...Online...

Folder Lock without any S/W
Here you go with an alternative way to lock folders without the use of any alternative software

Open Notepad and copy the below code and save as locker.bat. Don't forget to change your password in the code it's shown the place where to type your password.
Now double click on locker .bat
First time start it will create folder with Locker automatically for u. After creation of the Locker folder, place the contents u want to lock inside the Locker Folder and run locker.bat again. To release the lock again run locker.bat. It prompts to enter your password. On entering the correct password we can unlock the folder.

I hope this comes in handy J

**********************************************************
cls
@ECHO OFF
title Folder Locker
if EXIST "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}" goto UNLOCK
if NOT EXIST Locker goto MDLOCKER
:CONFIRM
echo Are you sure u want to Lock the folder(Y/N)
set/p "cho=>"
if %cho%==Y goto LOCK
if %cho%==y goto LOCK
if %cho%==n goto END
if %cho%==N goto END
echo Invalid choice.
goto CONFIRM
:LOCK
ren Locker "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}"
attrib +h +s "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}"
echo Folder locked
goto End
:UNLOCK
echo Enter password to Unlock folder
set/p "pass=>"
if NOT %pass%==type your password here goto FAIL
attrib -h -s "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}"
ren "Control Panel.{21EC2020-3AEA-1069-A2DD-08002B30309D}" Locker
echo Folder Unlocked successfully
goto End
:FAIL
echo Invalid password
goto end
:MDLOCKER
md Locker
echo Locker created successfully
goto End
:End

2)Share Folders and Files online
1)Scribd.com
2)esnips

Thursday, May 15, 2008

Frequently needed source Code for WebApplications

In this post I am going to enlist the sources for generalise asp.net web applications
1)Spellcheck for Web
Its a very easy way to integrate the spellchecker with less efforts
step I Download the required files
Extract and copy
webdir.wsf ,bin ,dic ,doc ,lib, src, web.config files and folders to root folder
step II Just include the js file spell.js
step III Call the function checkSpelling() on button click


2)Hidden control to get javascript variable value at server side

Thursday, May 8, 2008

Hands-On articles by MVPs

1)Articles by Bilal Haider on aspalliance
2)Some Practicals using Ajax
3)Matt Bersett's excellent Articles
4)Learn In asynchronus Way
....Some more yet to be added

Convering SQL resultset to XML file

Hello All,
Here's the simplest way to convert SQL result to XML output
-- declare an XML variable
DECLARE @x XML
SET @x = ''

-- create another XML variable
DECLARE @t XML
SELECT @t = ( SELECT TOP 3 name FROM sys.tables FOR XML AUTO)

-- insert the second XML variable to the first one
SET @x.modify( '
insert sql:variable("@t")
as last into (/Root)[1] ' )

-- Let us check the results
SELECT @x

/*





*/

Monday, May 5, 2008

Adding Attributes to Server Controls

Hi
If you dont find the required property of a partcular control like Linkbutton
Add the attributes to this control as follows
lnkButton.Attributes.Add("Target", "frame");
Basicaly when linkbutton is rendered at client side ,its in form of anchor control
so All server controls are have the attributes of corresponding html controls
in above case linkbutton have attributes of anchor control.
If you have additional comments on this .please post your most valuable comments
thanxs

Tuesday, March 18, 2008

Technology Geeks

Useful computer Geeks









Auto email on commit in CVS





Geeks by hosam kamel -A must Read
Geeks by Ryan Ternier -A must Read
Some more geeks.. Yet to be Added