Thursday, 13 November 2014

Maximum stored procedure, function, trigger, or view nesting level exceeded (limit 32)

When you execute your procedure in your database then a very common error of MSSQL "Maximum stored procedure, function, trigger, or view nesting level exceeded (limit 32)."
comes often.
Solution to this problem is when you execute your procedure then then use keyword 'Go' between final 'end' and exec procedure
ALTER procedure [dbo].[test]
@a nvarchar(50),
@b nvarchar(50)
 declare @id int
 declare @Aid2 int 
 declare @counter int
                    select 1

exec test 'starplus','starplus7'

This will solve your problem.......


Monday, 12 May 2014

Send Notification to selected users in Asp.Net

Suppose in your website there is an admin control and you want to deliver a message to all or selected users i.e. after login only selected users or every user can see the notification or message from admin of website.
How this task can be achieved?
Follow the following steps. 
1.  Make separate table for message and in login table make another column with bullion type so that whenever it is true user can see the message and we will have to check at the time of login whether this field is true or false. If this is true then user is able to see message stored in database by admin. 

2. On admin side. Make web page like this then admin can search user by name and primary key should be stored separately so that many users can be enabled to see notification. In the image when admin search user by name their primary key will appear to see how many person he want to send notification.

  When admin search name will be automatically added in list.

Create a function and it will be called when search button click event is called.
public void select_users()
        using (SqlConnection con = new SqlConnection(constr))
            using (SqlCommand cmd = new SqlCommand("select name from tablet where appmstregno='"+TextBox1.Text+"'",con))
                SqlDataReader dr = cmd.ExecuteReader();
                while (dr.Read())
                    Label1.Text = Label1.Text+dr["name"].ToString()+",";
                    // binding various name in label to show.

Now after this when send notification button is clicked we will have to separate all name so that we can update bullion type column to true. Ro accomplish this task we will have to take all name in a string type array and by using foreach method we can execute SQL query.

string[] arra = Label1.Text.Split(',');
        foreach (string k in arra)

            using (SqlConnection con = new SqlConnection())
                using (SqlCommand cmd = new SqlCommand("update table nameset bool_type_column=1 where name='"+k+"'", con))


By this way we can achieve our goal. If you want to send notification to all user no need to search just update bull_type_column from false to true.

Tuesday, 8 April 2014

Send SMS on Mobile for Verification or Anything in ASP.Net

To do this you will have to purchase SMS service , I don't know whether this service is free or not but you will have to purchase it.
Okay, Take two textbox one for mobile no and one for some code you want to send and one button to click
When user enters mobile no message automatically goes to it's mobile no you can dynamically assign random code for user but here I am using textbox to send code.
now take an iframe and give it an id 'frame_id' and in the button click event assign src attribute dynamically, it will send code to its corresponding mobile no.

make a function

protected void sms_send_method()
string string_of_connection=""; // here you will have to write connection of sms url given by company you purchased

frame_id.Attributes["src"]= string_of_connection;


Monday, 10 February 2014

Infinite Scroll in Asp.Net C# using Javascript without Third party Plugin

Infinite Scroll is very common today in website as we all see in facebook, google+ , LinkedIn and many other sites, as we scroll down data from server automatically appears in our browser without clicking any button.
How We will do it? 
We first create a database and then after that we will apply a jquery that will execute when our scroll bar reaches bottom of the page.

For demo I will fetch YouTube video link from local server and bind that in iframe when scrolled down..

 Here I will define a variable or you can say in other word a counter that will increase according to our requirement when scroll down. and that value will pass to the server so that server can send data when scrolled down.
Here in my example I am increasing counter by one and initial value is 14 since my table ID started from 14 (you know when you delete some data this happen when it is PK)
How to pass data from a page to server using jquery?

Follow these Steps:
1. Create a new project and include two page 1. index.html and 2. Default.aspx
2. Now Create a table from which you want to fetch data and display in index.html. You can see my table in the image above.

3. Now open index.html and  write the following code.

    <title>Auto Scroll</title>
    <script type="text/javascript" src=""></script>
    <script type="text/javascript" src=""></script>
    <script type="text/javascript">

        var j = 15;// variable j is assigened initial value (according to my requirment you can set any value)
        function ram() {// this function increases the value of variable j after calling function abc() that passes
            abc(j);     // data from client to server and get data returned here i am passing value of J to server.
        j = j;
        function abc(k) {// this function uses ajax to communicate with server
                type: 'post',
                contentType: "application/json; charset=utf-8",
                url: 'Default.aspx/increasediv',
                // Here InsertMethod is a function on page name datainsertusingjquery.aspx                 
                data: "{'id':'" + k + "'}",// passing value of j in k and this k to function increasediv in code behind of Defalut.aspx
                async: false,
                success: function (response) {

                    document.getElementById('para').innerHTML = response.d;// this bind data in div which id is 'para'
                error: function (response) {




        $(window).scroll(function () {// this function check whether scroll reached at the bottom of browser
            if ($(window).scrollTop() == $(document).height() - $(window).height()) {

                ram();// if it reached at botton call the function ram()

<div style="height:1000px; width:100%">
<!--<input type="button" id="shashi" value="submit" onclick="ram()" />-->
<div id="para"></div>

  To read flow see this image

 4. Now, Default.aspx.cs file should contains the increasediv function so that it is called when ajax function if fired by client. see this code.


    public static string increasediv(string id)
        string shashi;
        StringBuilder sb = new StringBuilder();// string builder object
     SqlConnection con = new SqlConnection("Data Source=analog-PC;Initial Catalog=experiment;Integrated Security=True");
        con.Open();// sql connection
        SqlCommand cmd = new SqlCommand("select Youtube from Mov where ID<"+id,con);// sql query as we receive id from ajax on client side page
        SqlDataReader dr = cmd.ExecuteReader();// reader object
        while (dr.Read())
            sb.Append("<iframe src='"+dr[0].ToString()+"' alt='' height='300px' width='400px'></iframe><br/>");// appending this in object in iframe
        shashi = sb.ToString();
        return shashi;// returining this string to client page to bind in html page....
 You can see this video also to get helped more..