Thursday, May 11, 2017

Cannot create/reset deployment credentials on an Azure Web App?

Introduction:-

Today i will explain you "Cannot create/reset deployment credentials on an Azure Web App?"How can resolve the issue.



Having typed a (valid) user name and (valid) password, I pressed the tick to confirm creation/reset. It led me to error message like this (Failed to Set Credentials with error: "Please, try again. If the problem persists, contact support."


Solution (workaround)

Set Username and password and save it,After saving below output get. 


IF you follow all step than your problem will resolve.

-------------------------Thank you----------------------------

Monday, May 8, 2017

How to fill gridview from datatable in asp.net

Introduction:-


Hello all today i will explain you "How to fill gridview from datatable in asp.net"

Please follow the below steps:-

1)Create a connection string in Web.config File.

 <connectionStrings>
    <add name="sqlConnecrtion" connectionString="Data Source=MICROSOFTDOTNET;Initial Catalog=SEPTNew;Trusted_connection=True" />   
  </connectionStrings>

2) Drag the GridView on to the .aspx page.

3) write the below code in your .aspx.cs file.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;

namespace WebApplication1
{
    public partial class WebForm1 : System.Web.UI.Page
    {
        string _con = ConfigurationManager.ConnectionStrings["sqlConnecrtion"].ConnectionString;
        protected void Page_Load(object sender, EventArgs e)
        {
           if (!IsPostBack)
            {
               
               getdata();
            }

            }
        private void getdata()
        {
            DataTable dt = new DataTable();
            using (SqlConnection con = new SqlConnection(_con))
            {
con.open();
                string str = "Select * from City_Master ";
                using (SqlCommand cmd = new SqlCommand(str,con))
                { 
                    using(SqlDataAdapter sd=new SqlDataAdapter(cmd))
                    {
                        sd.Fill(dt);
                    }
                
                
                }
            
            }
            GridView1.DataSource = dt;
            GridView1.DataBind();
        
        }
        
    } 
}


Execute your program using F5 or start project.



--------------------------Thank you ------------------------- 



How to fill the GridView using SqlDataReader in asp.net C#

Introduction:-


Hello all today i will explain you "How to fill gridview from SqlDataReader in asp.net c#"

Please follow the below steps:-

1)Create a connection string in Web.config File.

 <connectionStrings>
    <add name="sqlConnecrtion" connectionString="Data Source=MICROSOFTDOTNET;Initial Catalog=SEPTNew;Trusted_connection=True" />   
  </connectionStrings>

2) Drag the GridView on to the .aspx page.

3) write the below code in your .aspx.cs file.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;

namespace WebApplication1
{
    public partial class WebForm1 : System.Web.UI.Page
    {
        string _con = ConfigurationManager.ConnectionStrings["sqlConnecrtion"].ConnectionString;
        protected void Page_Load(object sender, EventArgs e)
        {
           if (!IsPostBack)
            {
               
               gatdataUsingReader();
            }

            }
        private void gatdataUsingReader()
        {
            using (SqlConnection con2 = new SqlConnection(_con))
            {
                con2.Open();
                using(SqlCommand cmd1=new SqlCommand("Select * from sales",con2))
                {
                    SqlDataReader dr = cmd1.ExecuteReader();
                    GridView2.DataSource = dr;
                    GridView2.DataBind();
                } 
            }
        }
        
        }
        
    } 
}


Execute your program using F5 or start project.



--------------------------Thank you ------------------------- 


Read value from database using dataset with StoredProcedure and bind in GridView.

Introduction:
In this article I will explain how to bind gridview with datareader in asp.net using C#.net

Implement 

Open Your IDE
 File ----New----Project



Click on project----Web

 
change Name What you want---Click Ok Button



Click on Default.aspx page and Drag the gridview from Toolbox.




The connection string in web.config file 
e.g:-
<connectionStrings>
    <add name ="DBM" connectionString ="Data Source=your system name;Initial Catalog=your database name;Integrated Security=True"/>
  </connectionStrings>

Note:- I am using window authentication  so using Integrated Security=True;

Add the following namespace:-

Using Sysytem.Data;Using System.Data.SqlClient; Know time to come you  write code in Page_load
        string strcon = System.Configuration.ConfigurationManager.ConnectionStrings["DBM"].ConnectionString;
        protected void Page_Load(object sender, EventArgs e)
        {
if(!IsPostback){
            BindGridView();
}
        }
        public void BindGridView()
        {
            //connect to database via dataset & dataadapter
            SqlConnection con = new SqlConnection("server=localhost;Initial Catalog=databasename;uid=;pwd=;");
            DataSet ds = new DataSet();
            SqlDataAdapter da = new SqlDataAdapter("GetstudentnameInOutputVariable", con);
            da.SelectCommand.CommandType = CommandType.StoredProcedure;
            da.Fill(ds);
          gridview1.DataSource =ds;
gridview1.DataBind();      
        }
       
 


------------------Thank you-------------------------