How to create Trigger in SQL server ?


Thursday, December 16, 2010

In this post you can see, how to create trigger in SQL server 2005/2008


ALTER TRIGGER t_XYZ_Update 
   ON  tbl_tableName1
   AFTER UPDATE
AS 
IF ( UPDATE (tableField1) OR UPDATE (tableField2) OR UPDATE (tableField3) OR UPDATE (tableField4))
    BEGIN
    SET NOCOUNT ON;
    
    DELETE FROM tbl_tableName2 WHERE FieldId=(select FieldId from inserted)
    print 'Row Deleted Successfully'
    END
GO



Name you trigger like below line

ALTER TRIGGER t_XYZ_Update


Assign the table name on which you have to perform operation like below line


ON  tbl_tableName1


Design when you want to allow this trigger to get fire, here let take after UPDATE operation.


AFTER UPDATE


If any of the tbl_tableName1 field like tableField1,tableField2,tableField3,tableField4 get updated outside by query or in SP, then this trigger will get fire and perform operation assign to this trigger, you can find when field get updated by below query,

 
IF ( UPDATE (tableField1) OR UPDATE (tableField2) OR UPDATE (tableField3) OR UPDATE (tableField4))



Here in below box, you can see the operation you want to perform when this trigger get fire, here we have used "inserted" table, whenever any of field found updated, same row is inserted in "inserted" table so by this table you can find which row is updated and you can make use of that rowid to perform other operation,

 
    BEGIN
    SET NOCOUNT ON;
    
    DELETE FROM tbl_tableName2 WHERE FieldId=(select FieldId from inserted)
    print 'Row Deleted Successfully'
    END



Hope this post will help you,
if yes please put comment below of this page,
Rajesh Singh,
Senior Asp.Net Developer

Email: raj143svmit@gmail.com
e-Procurement Technologies Ltd (India)
www.abcprocure.com

Prevent table from drop and re-create during saving changes


Thursday, December 2, 2010

Hello Friends,

Problem : Whenever you make any changes in the table defination, when table is fill with data or rows,it does not allow you to delete or make any changes to table.


Solution : You might have faced this issue many times, when ever you make any changes in the table defination and you try to save changes, then you might have seen error messages as shown in below image.




So here is the steps by which you can avoid dropping of table or re-creating it again by using below steps..

Step 1. There is one option in sql server, which allow you to save your changes to table without droping it.

You just click on Tool option in top menu, See below images you can see from where you can go to tool option,




Step 2. Then click on "Option",
then you will be prompt with options Box, in that you will see left menu, in that explore "Designers" option.


After Exploring Designers option, just click on "table and database designer", you will see below screen

Step 3. In below snap, you can see the field in Red Box, just untick it, so that you can save change.



Untick - Prevent saving changes that require table re-creation


Hope this post will help you,
if yes please put comment below of this page,
Rajesh Singh,
Senior Asp.Net Developer
Email: raj143svmit@gmail.com
e-Procurement Technologies Ltd (India)
www.abcprocure.com

Use of ROLLBACK in SQL server Stored Procedure


Wednesday, November 17, 2010

Use of ROLLBACK in SQL server Stored Procedure

You might have heard about ROLLBACK but you have never used it right ?

If you have used it, its well and good but if Not, then this blog might help you to know, how you can use ROLLBACK in your SP.

Suppose you want to use two insert statement, one by one.

You want to use, @@identity of first insert in another insert statement then this is the best method to go with.

Suppose you are doing first insert operation and some problem occure and any how you are not able to insert data in second table then there might be some database mapping issue.

so here, ROLLBACK can help you to avoid such database problem,

For example, you have used ROLLBACK in your SP, and you are doing first insert operation and if some problem occur and you are not able to insert in second table then ROLLBACk will undo your first insert operation also which will help to avoid database mapping issue.


Below is the syntax of ROLLBACK,


BEGIN TRY
    BEGIN TRAN
    BEGIN
        'You insert statement
                            
        COMMIT TRAN
                    
    END
END TRY
 
BEGIN CATCH
    BEGIN
        ROLLBACK TRAN
                    
        PRINT ERROR_MESSAGE()
    END
END CATCH




Hope this post will help you,
if yes please put comment below of this page,
Rajesh Singh,
Senior Asp.Net Developer

Email: raj143svmit@gmail.com
e-Procurement Technologies Ltd (India)
www.abcprocure.com


Wishing Happy Diwali to all Asp.Net Developers


Thursday, November 4, 2010




Hope this post will help you,
if yes please put comment below of this page,
Rajesh Singh,
Senior Asp.Net Developer

Email: raj143svmit@gmail.com
e-Procurement Technologies Ltd (India)
www.abcprocure.com

Trick to place jQuery Validation Error


Sunday, October 31, 2010

In this post, i will show you, how to place jQuery error where you like.

By default, when you use jquery validation function, then error get placed below the control for which you are validating.

But sometime, situation arise, you want jQuery error to be shown someother place for that control, so in that condition, you can use below trick and place error, where you like.

To do this,

You have to declare jquery files in your Page Head Tag, as shown below.


<script type="text/javascript" src="../resources/js/jQuery/jquery-1.4.3.min.js"></script>
<script type="text/javascript" src="../resources/js/jQuery/jquery.validate.js"></script>



After declareing files, just use below code to validate the control


        <script type="text/javascript">
            $(document).ready(function() {
                $("#frmPEOfficeCreation").validate({
                    rules: {
                        txtdepartment: { required: true }
                    },
                    messages: {
                        txtdepartment: { required: "<br/>Please select department" }
            }
                });
            });
        </script>


You can see below Image as output, where you can see, the error is shown after "new window" button, that is not looking good and not correct with respect to layout.



so Now what you can do is,you can make use of errorplaceholder function avalible in jQuery, LIke i have done below


<script type="text/javascript">
            $(document).ready(function() {
                $("#frmPEOfficeCreation").validate({
                    rules: {
                        txtdepartment: { required: true }
                    },
                    messages: {
                        txtdepartment: { required: "<br/>Please select department" }
            },
                    errorPlacement: function(error, element) {
                        if (element.attr("name") == "txtdepartment")
                            error.insertAfter("#btnnewbutton");
                        else
                            error.insertAfter(element);
                    }
                });
            });
        </script>


Then you can see correct layout, shown below in image



Hope this post will help you,
if yes please put comment below of this page,
Rajesh Singh,
Senior Asp.Net Developer

Email: raj143svmit@gmail.com
e-Procurement Technologies Ltd (India)
www.abcprocure.com

Load images when the user scrolls down to each image


Thursday, September 30, 2010

This article shows you, How you can save loading time of your web page by not allowing unwanted images to get load.

Your webpage load time increases by loading lots of images, after reading this article and implementing this effect on your

page, you can decrease your page load time almost 30%.

So Only allow images to get load on browser when it is needed, i.e when you scroll down to page, whereever images are there,
than perticular images will load at that time only.

You can achive this by using Jquery function called LazyLoad,

So to achive this, you will need to add Jquery File jQuery-1.4.1.js and one more file Jquery_002.js

You can download both file from here
http://www.filefactory.com/file/b3bcaaf/n/JS.zip



<script language="jscript" type="text/javascript" src="js/jquery-1.4.1.js"> 

</script> 
<script src="JS/jquery_002.js" type="text/javascript"></script>


After including above two files in your page, you will need to add below javascript file on top in head part of Page.


<script type="text/javascript">
    jQuery(document).ready(function($) {

        if (navigator.platform == "iPad") return;

        jQuery("img").lazyload({
            effect: "fadeIn",
            placeholder: "images_b/grey.gif"
        });
    });
</script>


Note : if you are using iPhone or iPad, then you might be familier with this effect, when you scroll down on page in iphone,
Images loads on that part only.

Hope this post will help you,
if yes please put comment below of this page,
Rajesh Singh,
Senior Asp.Net Developer
Email: raj143svmit@gmail.com
e-Procurement Technologies Ltd (India)
www.abcprocure.com

How to get the value of radio button in JQuery


Monday, August 2, 2010

Suppose you have group of radiobuttonlist and you need to find which radio button is checked.

So By using below code you can find, which radio button is checked in radiobuttonlist


jQuery('#ctl00_ContentPlaceHolder1_rblSort input:radio:checked').val()


or

$("#ctl00$ContentPlaceHolder1$rblSort").data("currChecked", 

$(this).find("input:radio:checked")[0]);


Hope this post will help you,
if yes please put comment below of this page,
Rajesh Singh,
Senior Asp.Net Developer

Email: raj143svmit@gmail.com
e-Procurement Technologies Ltd (India)
www.abcprocure.com


How to get the value of session in JQuery




Sometime, its possible that you need to compare login session on clientside code only before server side.

You can achive this task by using below code.


var sessionValue = '<%= Session("UserName") %>';
if (sessionValue == 'Rajesh') 
{
Alert("This is Rajesh Singh");
}


Hope this post will help you,
if yes please put comment below of this page,
Rajesh Singh,
Senior Asp.Net Developer

Email: raj143svmit@gmail.com
e-Procurement Technologies Ltd (India)
www.abcprocure.com


Response.Redirect in Javascript or Jquery




In C# or VB.net, if you wish to redirect page to some other page then you normally use below code

In C#
Response.Redirect("default.aspx");

and In Vb.Net
Response.Redirect("default.aspx")

But what for Javascript and Jquery, how you will use redirect feature in Javascript and Jquery ?

Here is the solution,

You can achive this Response.Redirect feature in javascript and jquery also by below code,


window.location.href = 'http://' + '<%=Request.Url.Host%>' + '/default.aspx';


Hope this post will help you,
if yes please put comment below of this page,
Rajesh Singh,
Senior Asp.Net Developer

Email: raj143svmit@gmail.com
e-Procurement Technologies Ltd (India)
www.abcprocure.com


How to get Host Url in javascript or Jquery




Sometime, you will be in need of only host part of URL, like

if you url is http://www.induway.com/aboutus.aspx

then if you wish to have only "induway.com" out of complete url, then you can use this code to get host url
in javascript or jquery.


'<%=Request.Url.Host%>'


Hope this post will help you,
if yes please put comment below of this page,
Rajesh Singh,
Senior Asp.Net Developer

Email: raj143svmit@gmail.com
e-Procurement Technologies Ltd (India)
www.abcprocure.com


How to fetch the querystring variable in jQuery




Suppose you are having this Querystring

http://www.induway.com/aboutus.aspx?Industry='india'

and if you wish to fetch value of Industry then you can do it like this,


if ('<%=Request("Industry")%>' != '') 
{
    alert('<%=Request("Industry")%>');
}


By using above code, you can use querystring variable value to your page anywhere.

Hope this post will help you,
if yes please put comment below of this page,
Rajesh Singh,
Senior Asp.Net Developer

Email: raj143svmit@gmail.com
e-Procurement Technologies Ltd (India)
www.abcprocure.com


Replace space character in between string in Jquery




Replace space character in between string in Jquery

Sometimes it possible that we need string by all space character removed, so here is the way by which we can remove space

character from our string.

For Example :

Our string is "Rajesh Singh"

var searchvalue='Rajesh Singh'
var searchvaluetemp = searchvalue.replace(/ /g, '');

Our Output will be "RajeshSingh"

Hope this post will help you,
if yes please put comment below of this page,
Rajesh Singh,
Senior Asp.Net Developer

Email: raj143svmit@gmail.com
e-Procurement Technologies Ltd (India)
www.abcprocure.com


You can use this jquery file direclty from URL


Sunday, July 25, 2010

Hello friends,

Mostly what we do to apply jQuery validation to your form.

You download files from internet and add in your website and then use that.

but whats the guarantee that, it would be correct so here is the few URL, i am providing that you might use directly or you can even download to your website.

<script type="text/javascript" src="http://code.jquery.com/jquery-latest.js"></script> 
<script type="text/javascript" src="http://dev.jquery.com/view/trunk/plugins/validate/jquery.validate.js"></script> 

Hope this post will help you,
if yes please put comment below of this page,
Rajesh Singh,
Senior Asp.Net Developer

e-Procurement Technologies Ltd (India)
www.abcprocure.com

Code to execute database operation and return value in Integer




Hello,

Here in below code you will find, how to do database operation in function in class and that function return Integer as return value.

SqlConnection conn = new SqlConnection("Data 
Source=localhost;Database=MyDB;Integrated Security=SSPI");
SqlCommand command = new SqlCommand("InsertUser", conn);
command.CommandType = CommandType.StoredProcedure;
command.Parameters.Add("@User", SqlDbType.VarChar).Value = user;
command.Parameters.Add("@Pass", SqlDbType.VarChar).Value = pass;
conn.Open();
int rows = command.ExecuteNonQuery();
conn.Close();


Hope this post will help you,
if yes please put comment below of this page,
Rajesh Singh,
Senior Asp.Net Developer

e-Procurement Technologies Ltd (India)
www.abcprocure.com


Code to execute database operation and return value in Dataset




Hello,

Here in below code you will find, how to do database operation in function in class and that function return dataset as return value.

SqlConnection conn = new SqlConnection("Data Source=localhost;Database=Northwind;Integrated Security=SSPI");
SqlCommand command = new SqlCommand("GetProducts", conn);
command.CommandType = CommandType.StoredProcedure;
command.Parameters.Add("@CategoryID", SqlDbType.Int).Value = 1;
SqlDataAdapter adapter = new SqlDataAdapter(command);
DataSet ds = new DataSet();
adapter.Fill(ds, "Products");
dataGrid1.DataSource = ds;
dataGrid1.DataMember = "Products";


Hope this post will help you,
if yes please put comment below of this page,
Rajesh Singh,
Senior Asp.Net Developer

e-Procurement Technologies Ltd (India)
www.abcprocure.com

How to create class file in Asp.Net ?




Hi,

You can just add App_Code file and add class file to this folder and copy this code to that class file and modify according to your need.

using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;
using commonlib.Common;

/// <summary>
/// Summary description for Program
/// </summary>
public class Program
{
    #region "Fields"

    string sOperation;
    int iProgramID;
    string sProgramName;
    string sSlogan;
    string sStartTime;
    string sEndTime;
    string sDetail;
    int iCityID;
    string sStatus;

    #endregion

    #region "Construtor"
    public Program()
    {
    }

    public Program(string SOperation, int IProgramID, string SProgramName, string SSlogan, string SStartTime, string SEndTime, string SDetail, int ICityID, string SStatus)
    {
        this.sOperation = SOperation;
        this.iProgramID = IProgramID;
        this.sProgramName = SProgramName;
        this.sSlogan = SSlogan;
        this.sStartTime = SStartTime;
        this.sEndTime = SEndTime;
        this.sDetail = SDetail;
        this.iCityID = ICityID;
        this.sStatus = SStatus;
    }
    #endregion

    #region "Properties"

    public string SOperation
    {
        get { return sOperation; }
        set { sOperation = value; }
    }

    public int IProgramID
    {
        get { return iProgramID; }
        set { iProgramID = value; }
    }

    public string SProgramName
    {
        get { return sProgramName; }
        set { sProgramName = value; }
    }

    public string SSlogan
    {
        get { return sSlogan; }
        set { sSlogan = value; }
    }

    public string SStartTime
    {
        get { return sStartTime; }
        set { sStartTime = value; }
    }

    public string SEndTime
    {
        get { return sEndTime; }
        set { sEndTime = value; }
    }

    public string SDetail
    {
        get { return sDetail; }
        set { sDetail = value; }
    }

    public int ICityID
    {
        get { return iCityID; }
        set { iCityID = value; }
    }

    public string SStatus
    {
        get { return sStatus; }
        set { sStatus = value; }
    }

    #endregion

    #region "Functions"

    public int ProgramOperation(string user, string pass)
    {

        SqlConnection conn = new SqlConnection("Data Source=localhost;Database=MyDB;Integrated Security=SSPI");
        SqlCommand command = new SqlCommand("XYZ_SP_CheckProgramAvailability", conn);
        command.CommandType = CommandType.StoredProcedure;
        command.Parameters.Add("@User", SqlDbType.VarChar).Value = user;
        command.Parameters.Add("@Pass", SqlDbType.VarChar).Value = pass;
        conn.Open();
        int rows = command.ExecuteNonQuery();
        conn.Close();

    }

    #endregion
}


Hope this post will help you,
if yes please put comment below of this page,
Rajesh Singh,
Senior Asp.Net Developer

e-Procurement Technologies Ltd (India)
www.abcprocure.com



How to give reference of other table to current table in fields?




Hello friends,

Thanks for all your support, Please read this new post to know how to give reference of other table to current table in fields.

You can find if any table with this name is exist in database of not, if you found delete it and create this one.

To do this operation use this code,

--Table Name: XYZ_SongRequest

    IF EXISTS (SELECT * FROM SYSOBJECTS WHERE ID = OBJECT_ID('XYZ_SongRequest'))
        DROP TABLE XYZ_SongRequest
    GO


Now by using below code, you can create reference of other table let say, XYZ_User, XYZ_City, XYZ_Rj to table XYZ_SongRequest

--Table Name: XYZ_SongRequest

CREATE TABLE XYZ_SongRequest (
    iRequestID            BIGINT            NOT NULL PRIMARY KEY IDENTITY(1,1),
    iMemberId            BIGINT            NOT NULL CONSTRAINT FK_SongRequest_iMemberId References XYZ_User(iMemberID),
    iCityID                INT                NOT NULL CONSTRAINT FK_SongRequest_iCityID References XYZ_City(iCityID),
    iRjId                INT                NOT NULL CONSTRAINT FK_SongRequest_iRjId References XYZ_Rj(iRJid),
    sRequest            VARCHAR(1000)    NOT NULL, 
    dRequestDate        DATETIME        NOT NULL DEFAULT GETDATE(),
    dProcessDate        DATETIME        ,
    sStatus                Varchar(20)        CHECK(sStatus in ('Pending','Approved')) NOT NULL DEFAULT 'Pending' 
)
GO


Hope this post will help you,
if yes please put comment below of this page,
Rajesh Singh,
Senior Asp.Net Developer

e-Procurement Technologies Ltd (India)
www.abcprocure.com


How to create Stored Procedure in SQL Server 2005 or 2008 ?




Solution :

You can directly copy below code highlight and paste in sql server query window and modify according to your need.

/**********************************************************************************
SP Name : XYZ_SP_ProgramOperation
Created by : Rajesh Singh
Created Date : 13th April 2010
Modified Date : 15th April 2010 
*********************************************************************************/

IF EXISTS (SELECT * FROM SYSOBJECTS WHERE ID=OBJECT_ID('XYZ_SP_ProgramOperation'))
DROP PROCEDURE XYZ_SP_ProgramOperation
GO 
create PROCEDURE XYZ_SP_ProgramOperation
(
    @sOperation varchar(100),
    @iProgramID INT=NULL,
    @sProgramName varchar(100)=NUll,
    @sSlogan varchar(100)=NUll,
    @sStartTime varchar(100)=NUll,
    @sEndTime varchar(100)=NUll,
    @sDetail varchar(MAX)=NUll,
    @iCityID INT=NUll,
    @sStatus varchar(20)=NUll
    
)
AS
IF @sOperation='SELECT'
            BEGIN
            SELECT * FROM [XYZ_Program] WHERE sStatus='Active'
            END
ELSE IF @sOperation='SELECTPROGRAMBYID'
            BEGIN
            SELECT XYZ_Program.*, XYZ_Rj.sUserName,XYZ_Rj.sPhoto, XYZ_Rj.sRjName,(select sCityName from XYZ_City where iCityId=XYZ_Program.iCityID) as sCityName,XYZ_RjProgRel.iRjId
            FROM   XYZ_Program INNER JOIN
            XYZ_RjProgRel ON XYZ_Program.iProgramID = XYZ_RjProgRel.iProgramID INNER JOIN
            XYZ_Rj ON XYZ_RjProgRel.iRjId = XYZ_Rj.iRJid WHERE XYZ_Program.iProgramID=@iProgramID
            END
ELSE IF @sOperation='UPDATE'
            BEGIN
            UPDATE [XYZ_Program]
               SET [sSlogan] = @sSlogan
                  ,[sStartTime] = @sStartTime
                  ,[sEndTime] = @sEndTime
                  ,[sDetail] = @sDetail
                  ,[iCityID] = @iCityID
                  ,[sStatus] = @sStatus
             WHERE XYZ_Program.iProgramID=@iProgramID
            END


GO


Hope this post will help you,
if yes please put comment below of this page,
Rajesh Singh,
Senior Asp.Net Developer

e-Procurement Technologies Ltd (India)
www.abcprocure.com


Where to put Connnectionstring in web.config file.




Hello bloggers,

Most of the developers have big confusion that, where to put connection string in web.config file,
So this article will teach you which portion you can use to write your connection string.
When you will open web.config file, you will find this tag
<connectionStrings />

Here what you can do is, just replace this string with below connectionstring.


Use this connectionstring when database is on other server or other computer.

<connectionStrings>
  
      <add name="conn" connectionString="Data Source=XYZ;Initial Catalog=DatabaseName;user id=UserId;password=Password; Max Pool Size=7500;Connect Timeout=200;" providerName="System.Data.SqlClient"/>
      
</connectionStrings>


when database is in your computer, you can use local database server.

<connectionStrings>

<add name="conn" connectionString="Data Source=localhost;Database=MyDB;Integrated Security=SSPI " providerName="System.Data.SqlClient"/>
      
</connectionStrings>


Hope this post will help you,
if yes please put comment below of this page,
Rajesh Singh,
Senior Asp.Net Developer

e-Procurement Technologies Ltd (India)
www.abcprocure.com

Encryption of Connection Strings Inside the Web.config


Wednesday, June 30, 2010

Motive : To Hide Database login details, whenever error occors in web.config file.

Explaination : you might have notice, if somethings goes wrong in web.config file, then yellow page appears with line number error and it is also possible it shows us connection string with database login details. So to hide that details, you need do few line code.



Your initial connectionstring will be like this :

<connectionstrings>
<add name="ConnectionString" connectionString="Data Source=JAVAL\SQLEXPRESS;Initial Catalog=WebTesting;Integrated Security=True"
      providerName="System.Data.SqlClient" />
</connectionStrings>



After Encryption, your final connectionstring will be like this:
<connectionstrings configProtectionProvider="DataProtectionConfigurationProvider">
<encrypteddata>
<cipherdata>
<ciphervalue>AQAAANCMnd8BFdERjHoAwE/Cl+sBAAAAQ4qWFMYeZkaDZbyFqQ9I7QQAAAACAAAAAAADZgAAqAAAABAAAADtQc027fRNV8+BRcNmjmWVAAAAAASAAACgAAAAEAAAAMHuX/gjWbtiwU0J8TSVSTewAQAA0CQYUjmcHyCzAvzE6GJN3oGZOwd5h0lwcPfhLjpgbySErnGHYNvWf58o4ieqhMFGduY0Sr9i8yqlDezbqyCrRQIri1qfl+6n2BFy3hQkZoTithLuilyCo+hOSq5rTP62aUm3FIjra1owCQmBV8/a34fu9zSgr4RRNQg1sg8yPFqHCssZPcA65MlXdJncTa6xBb6UpznFzcDF6N8z7LHPjF9baQEoeITw4TCY6yhM/6f7WIVWe2157GaBLGtoAuZP7z9ASrDKXmhQWQfsuwnaHcrE3JEUE/2yDmzxZFP+dY6FSqRzpWZoftgZnAIAnk2XeVsjqRy4zFNErFkzqxqhHNOMViodViRFZAJ5LRPAp6x3BkL/3F6d13Oa4gsbAlVY4+x60HdoItVXLoz+8Z3UNLfybN25cpQKSStw3TKnqSbzqtVyRjq1l+E/3lQSUxXSvgnA4mioGpaMAnMxNHnH3yRWiaYF37VfAHjCy8JhIJCtEBCmCUHh957KcggiRDXd2kpSb9M8CfHQQ4YJvm/YfOV3YwojIR6P2PHe5B6sizTuJxt/GTdKJ0nlVNxGr6TkFAAAAMbNEVnc4h11d1G1lz1pqOTtg2PJ</CipherValue>
</CipherData>
</EncryptedData>
</connectionStrings>


To do this please follow steps below,

First add this two namespace above your page:
Imports System.Configuration
Imports System.Web.Configuration


then Add this function anywhere in your code behind page :

Public Shared Function webencrypt()
Dim config As Configuration = WebConfigurationManager.OpenWebConfiguration("~")
Dim configSection As ConfigurationSection = config.GetSection("connectionStrings")

configSection.SectionInformation.ProtectSection("DataProtectionConfigurationProvider")
config.Save()
End Function


and call this function in pageload, like this
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Call webencrypt()
Dim sqlstring As SqlConnection
'sqlstring = New System.Configuration.ConfigurationManager.ConnectionStrings("conn").ConnectionString
sqlstring = New SqlConnection(ConfigurationManager.ConnectionStrings("ConnectionString").ConnectionString)
End Sub

Hope this post will help you,
if yes please put comment below of this page,
Rajesh Singh,
Senior Asp.Net Developer
e-Procurement Technologies Ltd
(India)
www.abcprocure.com


<%@ Page Language="C#"%>

<% User us = new User();
   bool result;

   if (Request["ctl00$ContentPlaceHolder1$txtusername"] != null)
   {
       result = us.checkUserAvailability(Request["ctl00$ContentPlaceHolder1$txtusername"].ToString(), "username");
       if (result)
       {
           Response.Write("true");
       }
       else
           Response.Write("false");
   }
   else if (Request["ctl00$ContentPlaceHolder1$txtemail"] != null)
   {
       result = us.checkUserAvailability(Request["ctl00$ContentPlaceHolder1$txtemail"].ToString(), "email");
       if (result)
       {
           Response.Write("true");
       }
       else
           Response.Write("false");
   }
   
 %>


source code :

<script type="text/javascript" language="javascript">
        $().ready(function() {
            $("#aspnetForm").validate({
                rules: {
                    ctl00$ContentPlaceHolder1$txtfirstname: {
                        required: true
                    },
                    ctl00$ContentPlaceHolder1$txtlastname: {
                        required: true
                    },
                    ctl00$ContentPlaceHolder1$txtpassword: { required: true, minlength: 5 },
                    ctl00$ContentPlaceHolder1$txtemail: {
                        required: true,
                        remote: "Controller/checkUserAvail.aspx",
                        email: true
                    },
                    ctl00$ContentPlaceHolder1$txtaddress1: { required: true }
                },
                messages: {
                    ctl00$ContentPlaceHolder1$txtfirstname: {
                        required: "<br/>Please enter First Name"
                    },
                    ctl00$ContentPlaceHolder1$txtlastname: {
                        required: "<br/>Please enter Last Name"
                    },
                    ctl00$ContentPlaceHolder1$txtpassword: {
                        required: "<br/>Please enter a password",
                        minlength: "<br/>Minimum password length is 5 characters"
                    },
                    ctl00$ContentPlaceHolder1$txtemail: {
                        required: "<br/>Please enter a email",
                        email: "<br/>Please enter a valid email",
                        remote: jQuery.format("<br/>Email address is already in use")
                    },
                    ctl00$ContentPlaceHolder1$txtaddress1: { required: "<br/>Please enter address"
                    }
                }
            });
        });         
    </script>

Thank
Rajesh singh

How to bind Datalist control from code behind ?


Wednesday, May 26, 2010

Solution :

This blog will explain you, how you can bind Datalist control from code behind.
First you need to add Datalist control in .aspx file, you can do this by draging the control form the toolbox or you can past e the below code in .aspx file.

Then you need to bind this control from the database, you can do this by assigning Datasource of control to dataset, find code for this also below.


Place below code in HTML file.

<asp:DataList ID="dlPhotos" runat="server" RepeatColumns="3" CellSpacing="0" CellPadding="5"
            RepeatDirection="Horizontal" Width="100%">
            <ItemStyle VerticalAlign="Top" />
            <ItemTemplate>
                <table cellspacing="0" cellpadding="0" width="100%" border="0" align="center">
                    <tr>
                        <td align="center" class="cellheightfifteen">
                            <a id="lnk<%#Container.DataItem("iProductImageID")%>" href="javascript:void(0)" 

onclick="removePhoto('<%=Application("SiteURL")%>ajaxopes.aspx','<%#Container.DataItem("iProductImageID")%>','<%#container.da

taitem("sImageFileName")%>')">
                                Remove Photo </a><span class="redlink" id="spn<%#Container.DataItem("iProductImageID")%>"
                                    style="display: none;"></span>
                        </td>
                    </tr>
                    <tr>
                        <td class="heightfive">
                        </td>
                    </tr>
                    <tr>
                        <td align="center">
                            <table id="tbl<%#Container.DataItem("iProductImageID")%>" 

width="<%=Application("THUMBIMAGEWIDTH") + 10%>"
                                height="<%=Application("THUMBIMAGEHEIGHT") + 10%>" border="0" cellspacing="0"
                                cellpadding="0" class="tblbox1">
                                <tr>
                                    <td align="center" id="tdImage" runat="server">
                                        <img 

src='<%=Application("SiteURL")%>Images/ThumbleImages/<%#container.dataitem("sImageFileName")%>?<%=now.tostring%>'
                                            alt='Loading...' />
                                    </td>
                                </tr>
                            </table>
                        </td>
                    </tr>
                    <tr>
                        <td align="center" class="cellheightfifteen">
                            <input type="radio" id="opt<%#Container.DataItem("iProductImageID")%>" name="rdPhoto"
                                onclick="setPhotoId('<%#Container.DataItem("iProductImageID")%>')" />
                        </td>
                    </tr>
                </table>
            </ItemTemplate>
        </asp:DataList>



Place below code in Code behind.

Code in VB.Net

If Not dsImage Is Nothing Then
       If dsImage.Tables(0).Rows.Count > 0 Then
          dlPhotos.DataSource = dsImage
          dlPhotos.DataBind()
       End If
End If

OR

Code in C#.Net

if ((dsImage != null)) 
{
        if (dsImage.Tables(0).Rows.Count > 0) 
    {
            dlPhotos.DataSource = dsImage;
            dlPhotos.DataBind();
        }
}


Hope this post will help you,
if yes please put comment below of this page,
Rajesh Singh,
Asp.Net Developer
Indianic Infotech Ltd (India)
rajesh@indianic.com


Populate Datagrid control using Stored Procedure.




Please follow below steps.

Step 1: Create Stored Procedure, see below code and modify according to your need.

CREATE PROCEDURE [dbo].[GetProducts] 
   (
       @CategoryID int
   ) 
AS
SELECT ProductID, ProductName FROM Products WHERE CategoryID = @CategoryID

Step 2: Please see below code and explaination for each line.

Complete Code

SqlConnection conn = new SqlConnection("Data 
Source=localhost;Database=Northwind;Integrated Security=SSPI");
SqlCommand command = new SqlCommand("GetProducts", conn);
command.CommandType = CommandType.StoredProcedure;
command.Parameters.Add("@CategoryID", SqlDbType.Int).Value = 1;
SqlDataAdapter adapter = new SqlDataAdapter(command);
DataSet ds = new DataSet();
adapter.Fill(ds, "Products");
dataGrid1.DataSource = ds;
dataGrid1.DataMember = "Products";


Explanation of above code line by line

Make sqlconnection using your connectionstring
SqlConnection conn = new SqlConnection("Data 
Source=localhost;Database=MyDB;Integrated Security=SSPI");

Declare sqlcommand and pass your Stored Procedure name and make connection to it.
All pass all the parameter to Stored Procudure.
SqlCommand command = new SqlCommand("GetProducts", conn);
command.CommandType = CommandType.StoredProcedure;
command.Parameters.Add("@CategoryID", SqlDbType.Int).Value = 1;

Declare sqldataadapter and assign command to this,
SqlDataAdapter adapter = new SqlDataAdapter(command);

Declare dataset and fill dataset using sqldataadapter and table name "Products".
DataSet ds = new DataSet();
adapter.Fill(ds, "Products");

Fill datagrid by dataset ds,
dataGrid1.DataSource = ds;
dataGrid1.DataMember = "Products";

Hope this post will help you,
if yes please put comment below of this page,
Rajesh Singh,
Asp.Net Developer
Indianic Infotech Ltd (India)
rajesh@indianic.com




Insert Form data in database using Stored Procedure




Please follow below steps.

Step 1: Create Stored Procedure, see below code and modify according to your need.

CREATE PROCEDURE [dbo].[InsertUser] (
    @User varchar(50),
    @Pass varchar(50)
) AS
INSERT INTO Users VALUES(@Username, @Password)

Step 2: Please see below code and explaination for each line.

Complete Code

string user = ... // get username from user
string pass = ... // get password from user

SqlConnection conn = new SqlConnection("Data 
Source=localhost;Database=MyDB;Integrated Security=SSPI");
SqlCommand command = new SqlCommand("InsertUser", conn);
command.CommandType = CommandType.StoredProcedure;
command.Parameters.Add("@User", SqlDbType.VarChar).Value = user;
command.Parameters.Add("@Pass", SqlDbType.VarChar).Value = pass;
conn.Open();
int rows = command.ExecuteNonQuery();
conn.Close();

Explanation of above code line by line

Assign your text box value to this variables
string user = ... // get username from user
string pass = ... // get password from user

Make sqlconnection using your connectionstring
SqlConnection conn = new SqlConnection("Data 
Source=localhost;Database=MyDB;Integrated Security=SSPI");

Declare sqlcommand and pass your Stored Procedure name and make connection to it.
All pass all the parameter to Stored Procudure.
SqlCommand command = new SqlCommand("InsertUser", conn);
command.CommandType = CommandType.StoredProcedure;
command.Parameters.Add("@User", SqlDbType.VarChar).Value = user;
command.Parameters.Add("@Pass", SqlDbType.VarChar).Value = pass;

Open connection to database and run your store procedure, thus you can insert your form data to database succussfully.
conn.Open();
int rows = command.ExecuteNonQuery();
conn.Close();

Hope this post will help you,
if yes please put comment below of this page,
Rajesh Singh,
Asp.Net Developer
Indianic Infotech Ltd (India)
rajesh@indianic.com



Manually Reset Identity Column Value in SQL Server


Saturday, May 1, 2010

Problem : If you are creating any table and using an identity column to that table, then at first time, when you insert any row, then identity value will start like 1,2,3... and so on..

But if you delete all the row from the table and when you try to insert new row in same table, the identity value will start from last identity value.

For Example the last identity was 6, so after deleting all data, when you insert new row, the identity value will be 7.

So to reset the identity Column value, you can use this below code.


Syntax

DBCC CHECKIDENT ( <table name>,RESEED,<new value>)

QUERY 

DBDD CHECKIDENT ('tbl_rajesh',RESEED,1)


Explaination :
table name = Your table name should be entered here
RESEED = this is used to reset your identity value.
new value = Starting identity value

If you want to check current identity value of any table, you can use below query.


DBCC CHECKIDENT (’tablename’, NORESEED)


Explaination :
table name = Your table name should be entered here
NORESEED = This will avoid RESEED function.

Hope this post will help you,
if yes please put comment below of this page,
Rajesh Singh,
Asp.Net Developer
Indianic Infotech Ltd (India)
rajesh@indianic.com

Solved : Microsoft SQL Server, Error:233


Friday, April 23, 2010

Issue : Microsoft SQL Server, Error:233

Solution :

Sometimes when you try to open sql server 2005 or 2008, after entering login details, you will be prompted by this below screen, telling "Microsoft SQL Server, Error:233", then you just get struck and restart you computer or even format the computer or uninstall sql server 2005 or 2008, but not getting any solution?



Please read below to find the solution to this issue.


At this time, what you need to do is, just open your network connection and just disable and enable once,as shown below and your problem solved, thats it. try to login again and you will be succussfully login.



Ya,i know you might be rubbing your head. i have even done that when i came to know the solution to this problem. but anyways finally you got solution to this problem.

Hope this post will help you,
if yes please put comment below of this page,
Rajesh Singh,
Asp.Net Developer
Indianic Infotech Ltd (India)
rajesh@indianic.com






unterminated string literal in jQuery


Thursday, April 22, 2010

Issue: unterminated string literal

Solution :





Whenever, you use textarea control in your html code, and you try to fetch the textarea data using jquery, you will encounter this 'unterminated string literal' issue.

Main reason of this issue is, while entering text in textarea control, if you press enter for new line, thus newline character is created, which make this issue to happen.

Please read below to find the solution to this issue,

suppose your html code is

HTML Code

<tr>
            <td align="right">
                About RJ :
            </td>
            <td align="left">
                <asp:TextBox ID="txtaboutrj" runat="server" TextMode="MultiLine" Width="300" Height="100"></asp:TextBox>
            </td>
        </tr>

To avoid this issue to happen, what you have to do is, just append '.ToString().Replace(Environment.NewLine, "<br />")' to your control name in code behind, like shown below.

CodeBehind Code

txtaboutrj.Text.ToString().Replace(Environment.NewLine, "<br />")

This will replace newline character with HTML tag "<br />",


Hope this post will help you,
if yes please put comment below of this page,
Rajesh Singh,
Asp.Net Developer
Indianic Infotech Ltd (India)
rajesh@indianic.com



Steps to Create Crystal Report in VB.NET


Thursday, March 25, 2010

In this tutorail, I will teach you how to make crystal report in vb.net.

Please follow the Steps to Create Crystal Report in VB.NET,

Step 1: Create one vb.net project in visual studio.

Step 2: what we need to create simple crystal report ?
a.Dataset file (.xsd)
b.Crystal Report (.rpt)
c.One window form (.vb)


Crystal report by Induway Technologies (www.induway.com)


Step 3: Right click on project name in visual studio and click on add to add new items.

Step 4: Select Dataset from the list from Add New Item displayed box.
Name it as ReportDS as shown in Video.
Then you will be prompt with gray screen, it shows you have created dataset properly.
Drag Table from the Server explorer and drop it on dataset gray screen.


Step 5: Now its time to insert report file (.rtp), right click on project name in visual studio and click on add to add new items.

Step 6: Select CrystalReport from the list from Add new item displayed box.
Name it as Crystalreport1 as shown in video.
Then you will be prompt with the Crystal Reports Gallery,
Just click on "OK", then another page "Standard Report creation Wizard" will be prompted.
Then you need to select the database you created, in step 4.
For that click on ADO.NET Dataset and select you dataset from the list.as shown in video.
Then you will be prompted with table with fields, select the fields you require to show in report.
Then click on finish, and you have done.

Step 7: Now you need to add from to show this report in it. To do that, just add new form (.vb), and drag the Reportviewer form the data section in tool box.

Step 8: Take one button in that from, so that, when you click on that button, the report show appear.

Step 9: Then on click event of that button, paste this code below.

Dim conn As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=PAMDB.mdb;User Id=admin;Password=;")
Dim cmd As OleDbCommand
cmd = New OleDbCommand("SELECT PAM_Medical_Information.tPatientName, PAM_Medical_Information.tDoctorCareProvider, PAM_Type_of_Medical_Entry.tMedicalTypeName, PAM_Medical_Information.tRx_OTC_MedsList_Dosage_Frequency, format(PAM_Medical_Information.dMedicalDate,'MM/dd/yyyy') as dMedicalDate , iif (PAM_Medical_Information.tPutOnMedicalInformationCard = '1', 'Yes', 'No') as tPutOnMedicalInformationCard FROM PAM_Medical_Information INNER JOIN PAM_Type_of_Medical_Entry ON PAM_Medical_Information.nMedicalTypeID = PAM_Type_of_Medical_Entry.iMedicalTypeID", conn) ' Change ID

Dim da As New OleDbDataAdapter(cmd)
Dim ds As New DataSet() 'Set TypeDataset name That I have created before
da.Fill(ds, "MedicalList")
If (ds IsNot Nothing And ds.Tables(0).Rows.Count > 0) Then
Dim cryRpt1 As New ReportDocument
Dim reportpath As String = Application.StartupPath & "\Reports\Medical.rpt"
'cryRpt1.Load(reportpath)
cryRpt1.Load(reportpath)
cryRpt1.SetDataSource(ds.Tables(0))
CrystalReportViewer1.ReportSource = cryRpt1
CrystalReportViewer1.Refresh()
End If



Thats it, you have done finally, enjoy the report.

Hope this post will help you,
if yes please put comment below of this page,
Rajesh Singh,
Asp.Net Developer
Indianic Infotech Ltd (India)
rajesh@indianic.com


.

How to define Global Variable in Windows Forms with C#




Create one Static class and declare static member/property into that class.

Now you can access that variable from any form in your windows application. Also you can able to set and get variable values.

GlobalModule Class:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

static class GlobalModule
{

private static string _GlobalVar = "";
public static string GlobalVar
{
get { return _GlobalVar; }
set { _GlobalVar = value; }
}

public static string FirstName = "Rajesh";
}



How to use global variables in application:


//Set the value to static variable
GlobalModule.GlobalVar = "VB.Net C#";

//Get the value from static variable
string CheckVal = GlobalModule.GlobalVar;
string FirstName = GlobalModule.FirstName;



Hope this post will help you,
if yes please put comment below of this page,
Rajesh Singh,
Asp.Net Developer
Indianic Infotech Ltd (India)
rajesh@indianic.com


.

How to get @@Identity after insert operation in Access Database


Saturday, March 20, 2010

Solution :

I am going to explain this in Vb.Net.

Create one vb.net project and add one from frmAddContact.vb in your project.
and take one button and txtbox in that form.

Create Dataaccesslayer class file with name, DAL.vb

and add below code to respective files, please find the code below.


frmAddContact.vb

Dim ObjDataAccess As New DAL()
Public Class frmAddContact
Dim ObjDataAccess As New DAL()

Private Sub btnsave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnsave.Click

Dim iRelationID As New Integer
iRelationID = ObjDataAccess.ExecuteNonQueryGetIdentity("INSERT INTO PAM_Relationship ( tRelationshipName,dCreatedDate,dModifiedDate) VALUES ('" & _
cmbrelationship.Text.Trim() & "',#" & _
Date.Now & "#,#" & _
Date.Now & "# )")

End Sub
End Class





DAL.vb

Imports System.Data.SqlClient
Imports System.Data
Imports System.Data.OleDb

Public Class DAL
Dim ConnStr As String = Configuration.ConfigurationSettings.AppSettings("DBConn").ToString()

Public Function ExecuteNonQueryGetIdentity(ByVal Query As String) As Integer

Dim iResult As Integer
Try
Dim Conn As New OleDb.OleDbConnection(ConnStr)
Conn.Open()
Dim cmd As New OleDb.OleDbCommand(Query, Conn)

cmd.ExecuteNonQuery()
cmd.CommandText = "Select @@Identity"
iResult = cmd.ExecuteScalar()
Conn.Close()
cmd.Dispose()
Catch ex As Exception
ex = Nothing
End Try

Return iResult
End Function

End Class


After insert operation, when you will check the value of return value of iRelationID, you will find the inserted row id.


Hope this post will help you,
if yes please put comment below of this page,
Rajesh Singh,
Asp.Net Developer
Indianic Infotech Ltd (India)
rajesh@indianic.com


.

Delete all image file from Perticular folder in C#


Friday, March 19, 2010

Hello DotNet Developer,

Please find below code, which will help to find all file in perticular folder and delete all the file and make folder blank.

Explaination of the code : Delete all image file from Perticular folder in C#

Here, i have find the folder path using Server.MapPath, then stored all the file in the array, i have named it imglist.

Then i have used forloop to get all the files name one by one and delete it,
Here i have taken DateTime.Now.AddMinutes, because if the file is added just before 3 minutes from the current time, then it should not be delete, you can change the time according to your need.

Code :

protected void CleanImageFolder()
{
string imgFolder = Server.MapPath("~/lab/maskemail/img/");
string[] imgList = Directory.GetFiles(imgFolder, "*.jpg");
foreach (string img in imgList)
{
FileInfo imgInfo = new FileInfo(img);
if (imgInfo.LastWriteTime < DateTime.Now.AddMinutes(-3))
{
imgInfo.Delete();
}
}
}



Hope this post will help you,
if yes please put comment below of this page,
Rajesh Singh,
Asp.Net Developer
Indianic Infotech Ltd (India)
rajesh@indianic.com

Steps to find Device ID of your iPhone or iPod Touch


Thursday, February 11, 2010

Steps to find Device ID of your iPhone or iPod Touch

Please follow below steps to find Device ID of your iPhone or iPod Touch.

Step 1: Open iTunes

Step 2: Connect your iPhone with Mac.



Step 3: when you will get successfully connected to iTunes, At the right pane, You will see each and every information of your iPhone,



Like
Name,
capacity,
software version,
serial number, and
phone number.

Then you can select that Serial Number and copy to your clipboard by selecting Edit → Copy.



Thus you can get your Device id by above steps.


Hope this post will help you,
if yes please put comment below of this page,
Rajesh Singh,
Asp.Net Developer
Indianic Infotech Ltd (India)
rajesh@indianic.com

How can I find current OS version of my iPhone ?




Steps to find Your iPhone or iPod Touch OS Version

Question : How can I find current OS version of my iPhone ?

Answer: Follow the steps to find your iphone or ipod touch OS version.

Step 1: Go to Settings of your Device

Step 2: Click on General option in that, You will see About page.See image.



Step 3: in that you can see the OS version of your Device.

Hope this post will help you,
if yes please put comment below of this page,
Rajesh Singh,
Asp.Net Developer
Indianic Infotech Ltd (India)
rajesh@indianic.com

Steps to Create Web Services in C# and Sql Server




Steps to Create Web Services in C# and Sql Server

Step 1: Create one website project in the visual studio

Step 2: Create one folder with name “WebServices” in the project.

Step 3: Right click on the folder and click on add new item, then select “ web services” file from the list, as shown in image below



Step 4: After creating file in folder, Webservices.asmx file will be created in the folder and a default folder with name “App_Code” will be added the project and new file with the name “Webservices.cs” file will be added to it automatically.

Step 5: Then create three class file in App_Code folder with name :

a.WebService_Class.cs
We will create all the function of database operation here. We will discuss this in detail below.

b.Webservice_Main.cs
In this class, we will store the generic list of web services data. We will discuss this in detail below.

c.WebServices_StoreLocalVariable.cs
In this class we will store all the local variables, so that we can speed up web services. We will discuss this in detail below.

WebService_Class.cs


You can add this code in this file


using System;
using System.Data;
using System.Configuration;
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 commonlib.Common;

/// <summary>
/// Summary description for WebService_Class
/// </summary>

namespace EuroCity
{

public class GetAllCityClass
{
#region "Fields"

private int iCityID;
private string sCityName;


DBManager DM = new DBManager(ConfigurationManager.ConnectionStrings["ConnectionString"].ToString());
#endregion

#region "Properties"

public int ICityID
{
get { return iCityID; }
set { iCityID = value; }
}

public string SCityName
{
get { return sCityName; }
set { sCityName = value; }
}

#endregion

#region "Function"

public DataSet GetAllCity()
{
DataSet DSCity = new DataSet();
string SQL = "SP_GetAllCity";

try
{
DSCity = DM.ExecuteDataSet(CommandType.StoredProcedure, SQL);
}
catch (Exception ex)
{
ex = null;
}
finally
{
if (DSCity != null)
{
DSCity.Dispose();
}
}
return DSCity;
}
#endregion
}
}




Webservice_Main.cs


You can add this below code in this file.

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.Collections.Generic;
using EuroCity;
/// <summary>
/// Summary description for WebServices_Main
/// </summary>
namespace EurocityCards_Classes
{
public class WebServices_GetAllCity
{
public string ErrorMessage = "";
public bool IsError = false;

public List<GetAllCityClass> CityList = new List<GetAllCityClass>();
}
}



WebServices_StoreLocalVariable.cs


You can add this below code in this file

using System;
using System.Data;
using System.Configuration;
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;

/// <summary>
/// Summary description for WS_EuroClass
/// </summary>
public class GetAllCityClass
{
#region Data Member
public string iCityID, sCityName;
#endregion
}


WebService.cs


Add Below code in the WebService.cs, that generated automatically in the App_Code file.



using System;
using System.Web;
using System.Collections;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Data;
using System.Data.SqlClient;
using EurocityCards_Classes;
using System.Collections.Generic;
using System.Configuration;
using EuroCity;



/// <summary>
/// Summary description for WS_EurocityCards
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class WebService : System.Web.Services.WebService
{
[WebMethod]
public WebServices_GetAllCity GetAllCity()
{
EuroCity.GetAllCityClass objcity = new EuroCity.GetAllCityClass();
DataSet dscity = new DataSet();
WebServices_GetAllCity WS_city = new EurocityCards_Classes.WebServices_GetAllCity();
dscity = objcity.GetAllCity();
objcity = null;
if (dscity != null && dscity.Tables[0].Rows.Count > 0)
{
WS_city.IsError = false;

List<GetAllCityClass> stateList = new List<GetAllCityClass>();

foreach (DataRow dtRow in dscity.Tables[0].Rows)
{
GetAllCityClass objcityName = new GetAllCityClass();
objcityName.iCityID = dtRow["catid"].ToString();
objcityName.sCityName = dtRow["Catname"].ToString();
stateList.Add(objcityName);

}

WS_city.CityList = stateList;
}
else
{
WS_city.ErrorMessage = "No record Found";
WS_city.IsError = true;
}

return WS_city;

}


}




Add Below code in the web.config file for the connection to the database


<connectionStrings>
<add name="ConnectionString" connectionString="Data Source=YOURSQLSERVERNAME;Initial Catalog=YOURDATABASENAME;user id=YOURDATABASEUSERNAME;password=YOURDATABASEPASSWORD;" providerName="System.Data.SqlClient;Max Pool Size=7500;Connect Timeout=500;pooling=true"/>
</connectionStrings>




To make database connection you need to create SP for that, please find code below


Create one Database in your SQL Server, and create one table name “SiteCity”

-- For City  Details
IF EXISTS (SELECT * FROM SYSOBJECTS WHERE ID = OBJECT_ID('SP_GetAllCity'))
DROP PROCEDURE SP_GetAllCity
GO
CREATE PROCEDURE [SP_GetAllCity]
AS
BEGIN
SELECT CityID,CityName
FROM SiteCity
ORDER BY CityName ASC
END
GO



After Creating the project, just build your application and run in brower.

Follow the screen to get your output.

Web Services First View
You will see the web service name here, see below in the image,



After clicking to the web services name, you will see "Invoke button"
This is the button used to run the web services.See in the screen below



Then finally you will see the below screen as output, what you were in need of, just call this and make you application successfull.




Hope this post will help you,
if yes please put comment below of this page,
Rajesh Singh,
Asp.Net Developer
Indianic Infotech Ltd (India)
rajesh@indianic.com

What is Google Buzz ?


Wednesday, February 10, 2010

Even google follow twitter,

This can be seen by this, that Google has implemented the twitter follow, as google buzz in google mail box.

This shows google know, the popularity of twitter.com

www.induway.com

Google is just trying to make your inbox as your admin panal of everything, means you can handle everything like contacting your friends, sending scrap to them, intracting with them and sharing feeling and makeing them aware what you are doing.

Google is just make your inbox social to internet.

Google's latest social media experiment came to life on Tuesday in the form of Google Buzz: a social media sharing service built into your Gmail window. Buzz will let you share photos, links, videos, and status updates through your Gmail inbox or your mobile device's Web browser.

Google is still rolling out the service to all Gmail users, but if you can't wait, we have a couple of ways that you can try out Buzz right now on your desktop or smartphone.

Hope this post will help you,
if yes please put comment below of this page,
Rajesh Singh,
Asp.Net Developer
Indianic Infotech Ltd (India)
rajesh@indianic.com

Failed to retrieve data for this request Error in SQL Server


Saturday, February 6, 2010

SomeTimes after formating your computer, when you install sql server 2008.

When you try to connect your database and click on database menu to see the list of database, you will find windows alert showing you this below error.




Microsoft SQL Server Management Studio

Failed to retrieve data for this request. (Microsoft.SqlServer.Management.Sdk.Sfc)

Additional information:

An exception occurred while executing a Transact-SQl statement or batch.(Microsoft.SqlServer.COnnectionInfo)

The server principal "DatabaseName" is not able to access the database "Birdiethis" under the current security context. (Microsoft SQL Server, Error:916)




Please read below to find, how to solve this problem,

There is nothing to worry about, mostly user use to uninstall sqlserver software and install it again. then also they feel same problem.

Follow this steps :

Step 1: Open your sql server 2008,connect to database.

Step 2: click on view option for the top menu panel,then click to Object Explorer Details,



Step 3: You will see a panel will open at the right hand side,

Step 4: Right click on the header part of that panel, and unselect all option, as shown in the image,



Step 5: This will solve that issue, and you can use sql server 2008 without any error.

That's it,


Hope this post will help you,
if yes please put comment below of this page,
Rajesh Singh,
Asp.Net Developer
Indianic Infotech Ltd (India)
rajesh@indianic.com

Important: Changes to Blogger FTP Service


Wednesday, February 3, 2010

Google Blogger is Going to Stop its services of allowing to host your blog on FTP.
Please read the notice below i have received one from GOOGLE.COM



Dear FTP user:

You are receiving this e-mail because one or more of your blogs at Blogger.com are set up to publish via FTP. We recently announced a planned shut-down of FTP support on Blogger Buzz (the official Blogger blog), and wanted to make sure you saw the announcement. We will be following up with more information via e-mail in the weeks ahead, and regularly updating a blog dedicated to this service shut-down here: http://blogger-ftp.blogspot.com/.

The full text of the announcement at Blogger Buzz follows.
Last May, we discussed a number of challenges facing[1] Blogger users who relied on FTP to publish their blogs. FTP remains a significant drain on our ability to improve Blogger: only .5% of active blogs are published via FTP — yet the percentage of our engineering resources devoted to supporting FTP vastly exceeds that. On top of this, critical infrastructure that our FTP support relies on at Google will soon become unavailable, which would require that we completely rewrite the code that handles our FTP processing.

Three years ago we launched Custom Domains[2] to give users the simplicity of Blogger, the scalability of Google hosting, and the flexibility of hosting your blog at your own URL. Last year's post discussed the advantages of custom domains over FTP[3] and addressed a number of reasons users have continued to use FTP publishing. (If you're interested in reading more about Custom Domains, our Help Center has a good overview[4] of how to use them on your blog.) In evaluating the investment needed to continue supporting FTP, we have decided that we could not justify diverting further engineering resources away from building new features for all users.


For that reason, we are announcing today that we will no longer support FTP publishing in Blogger after March 26, 2010. We realize that this will not necessarily be welcome news for some users, and we are committed to making the transition as seamless as possible. To that end:

    • We are building a migration tool that will walk users through a migration from their current URL to a Blogger-managed URL (either a Custom Domain or a Blogspot URL) that will be available to all users the week of February 22. This tool will handle redirecting traffic from the old URL to the new URL, and will handle the vast majority of situations.
    • We will be providing a dedicated blog[5] and help documentation
    • Blogger team members will also be available to answer questions on the forum, comments on the blog, and in a few scheduled conference calls once the tool is released.

We have a number of big releases planned in 2010. While we recognize that this decision will frustrate some users, we look forward to showing you the many great things on the way. Thanks for using Blogger.

Regards,

Rick Klau
Blogger Product Manager
Google
1600 Amphitheatre Parkway
Mountain View, CA 94043

[3] http://buzz.blogger.com/2009/05/ftp-vs-custom-domains.html

----
This e-mail is being sent to notify you of important changes to your Blogger account.