Thursday, December 20, 2012

Javascript for character count on keypress

 <script language="javascript" type="text/javascript">


maxL = 1000;
    var bName = navigator.appName;
    function taLimit(taObj) {
        if (taObj.value.length == maxL) return false;
        return true;
    }

    function taCount(taObj, Cnt) {
        objCnt = createObject(Cnt);
        objVal = taObj.value;
        if (objVal.length > maxL) objVal = objVal.substring(0, maxL);
        if (objCnt) {
            if (bName == "Netscape") {
                objCnt.textContent = maxL - objVal.length;
            }
            else { objCnt.innerText = maxL - objVal.length; }
        }
        return true;
    }
    function createObject(objId) {
        if (document.getElementById) return document.getElementById(objId);
        else if (document.layers) return eval("document." + objId);
        else if (document.all) return eval("document.all." + objId);
        else return eval("document." + objId);
    }


 </script>


==================
It is used like as mention below


 <asp:TextBox ID="txtImportaintInfo" runat="server" TextMode="MultiLine"
                                    CssClass="textarea_field2" Width="681px" onpaste="return false" onkeypress="return taLimit(this)" onkeyup="return taCount(this,'myCounter1')"></asp:TextBox>
                                   
<br />     You have <b><span id="myCounter1">1000</span></b>
                                characters remaining for your description...</td>

Tuesday, December 4, 2012

How to convert Sesstion object to array,arrylist in asp.net

converting sesstion to arry

 string[] arrFile = (string[])Session["arrFile"];

converting sesstion to arraylist

 Arraylist arrFile = (Arraylist)Session["arrFile"];

Adding Symbol like as ❏ and ❑ with string in asp.net

There is two sysbole  with shadow:

&#x274f;
&#x2751;

as ❏ and ❑

You can use it  and display like :


❏ Organising necessary form of order to transfer county court possession order to the High Court

❏ Shergroup Legal to attend High Court in London to organisecollection of necessary paperwork

❏ Experienced eviction locksmith on site to change locks and deal with roller shutters etc

❏ Shergroup Security to handle post eviction security services

❏ Shergroup Security to arrange post eviction cleansing

❏ Shergroup Security Risk Assessment Report to highlight measures to prevent further trespass or damage to      property

❏ Any other service not listed here – let us help you complete your eviction process


For this i have use various check box tick value and concatenated and displayed with this function

 private string ConcatCheckBoxText(CheckBox chkBox)
    {
        string str = chkBox.Checked ? "&#x274f; " + chkBox.Text + "<br/><br/>" : "";
        return str;
    }

This bold value in above function is responsible for adding these symbols  ❏ and ❑  in c#

Monday, November 26, 2012

Code for calling SSIS package in asp.net using c#


using System;
using System.Collections;
using System.Configuration;
using System.Data;
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 Microsoft.SqlServer.Server;
using Microsoft.SqlServer.Dts;
using Microsoft.SqlServer.Dts.Runtime;
using Microsoft.SqlServer.Dts.Runtime.Wrapper;
using Microsoft.SqlServer.Dts.Tasks.ScriptTask;
namespace CallPackage
{
    public partial class _Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void btnexecute_Click(object sender, EventArgs e)
        {
            try
            {
                Microsoft.SqlServer.Dts.Runtime.Application app = new Microsoft.SqlServer.Dts.Runtime.Application();
               Microsoft.SqlServer.Dts.Runtime.Package package = null;
                package =(Microsoft.SqlServer.Dts.Runtime.Package) app.LoadPackage(@"C:\Ajay\Package.dtsx",null,true);
                Microsoft.SqlServer.Dts.Runtime.DTSExecResult results = package.Execute();

                if (results == Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Failure)
                {
                    foreach (Microsoft.SqlServer.Dts.Runtime.DtsError local_DtsError in package.Errors)
                    {

                        Console.WriteLine("Package Execution results: {0}", local_DtsError.Description.ToString());
                        Console.WriteLine();
                    }
                }

            }
            catch (Exception ex)
            {
                string SS = ex.Message;
            }
        }
    }
}

SSIS Package using SQL Server Business Intellegence development Student

Is is used to transfer data in tables of two diffrent database

1.Add Data Flow Task

2.On the Data flow
    A).  Add OLE DB Source:double click and add database source connection string and choose table which need to transfer.
   B).Add OLE DB Destincation :double click and add database destination connection string and choose table in which data need to import.

now just run the application and Both source and destination OLE DB should be green heighlighted.It is a symbol of sucess or if it is showing red the there is error in package.

===============================================

Code for calling package in asp.net using c#



using System;
using System.Collections;
using System.Configuration;
using System.Data;
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 Microsoft.SqlServer.Server;
using Microsoft.SqlServer.Dts;
using Microsoft.SqlServer.Dts.Runtime;
using Microsoft.SqlServer.Dts.Runtime.Wrapper;
using Microsoft.SqlServer.Dts.Tasks.ScriptTask;
namespace CallPackage
{
    public partial class _Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void btnexecute_Click(object sender, EventArgs e)
        {
            try
            {
                Microsoft.SqlServer.Dts.Runtime.Application app = new Microsoft.SqlServer.Dts.Runtime.Application();
               Microsoft.SqlServer.Dts.Runtime.Package package = null;
                package =(Microsoft.SqlServer.Dts.Runtime.Package) app.LoadPackage(@"C:\Ajay\Package.dtsx",null,true);
                Microsoft.SqlServer.Dts.Runtime.DTSExecResult results = package.Execute();

                if (results == Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Failure)
                {
                    foreach (Microsoft.SqlServer.Dts.Runtime.DtsError local_DtsError in package.Errors)
                    {

                        Console.WriteLine("Package Execution results: {0}", local_DtsError.Description.ToString());
                        Console.WriteLine();
                    }
                }

            }
            catch (Exception ex)
            {
                string SS = ex.Message;
            }
        }
    }
}


    

Friday, November 23, 2012

How to find invalid characters in sql server


CREATE  FUNCTION  FindInvalidValid( @Name NVARCHAR(100) )

RETURNS BIT

BEGIN

    SELECT @Name = RTRIM(ltrim(@Name))

    IF(@name IS null) OR (@Name = '')

      RETURN 1



    DECLARE @len AS INT

    DECLARE @index AS INT

    DECLARE @ascii AS int

    SELECT @len =  LEN(@Name),@index = 1

    WHILE(@index <= @len)

    BEGIN

      SELECT @ascii = ASCII(substring(@Name,@index,1))

      IF ((@ascii BETWEEN 65 AND 90)

         OR (@ascii BETWEEN 97 AND 122)

         OR (@ascii BETWEEN 193 AND 252)

         OR (@ascii = 32)

         OR (@ascii = 45)

         OR (@ascii = 46)

         OR (@ascii BETWEEN 48 AND 57)

         )

      begin

         SELECT @index = @index + 1

         CONTINUE

      end

      ELSE

         RETURN 0

    END

    RETURN 1

END


================================

now use this query for geeting invalid charactor rows


SELECT *

FROM TracedCompanyDetailsttemp

WHERE dbo.IsNameValid(notes1) = 0

OR dbo.IsNameValid(notes1) = 0

Thursday, November 22, 2012

BCP command for Data moving from SQL server to SQL Azure


For making sql  tables to text data files at local drive

bcp databasename.dbo.Client out E:\Shergroup\SqlData\MoveDataFromSQLAzure.txt -c -U sa -S sherbasefive -P 12456

rk5n5pqf6u.database.windows.net


for coping from local dive text data files to sql azure

bcp databasename.dbo.Client in  E:\Shergroup\SqlData\MoveDataFromSQLAzure.txt -c -U myadmin@rk5n5p -S tcp:rk5n5p.database.windows.net -P c0r=jdb