Skip to main content

Posts

Login in asp.net using C# by webconfig file

Below is the code which will demonstrate how to design login functionality in asp.net using C# by with the help of web configuration file. Please note the login details are used as a static. The Web configuration file is:                                   The below is the design view of the project: <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Login.aspx.cs" Inherits="ShoppingHeart.Admin.Login" %>                                                                                Style="font-weight: 700">                                 ...

Cookie example in C# Asp.net

Below is the program which will show you how to maintain user page visit counts for web page using cookies. After each manual page refresh the count goes on increasing. Here us the code: using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; namespace cookie_example {     public partial class WebForm1 : System.Web.UI.Page     {         protected void Page_Load(object sender, EventArgs e)         {             int x = 0;             try             {                 HttpCookie c = Request.Cookies["mycookie"];                 if(c!= null)                 {                   ...

Maintain user page visit counts in C# asp.net

Below is the program which will show you how to maintain user page visit counts for web page. After each manual page refresh the count goes on increasing. Here us the code: using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; namespace show_user_visit_count_demo {     public partial class WebForm1 : System.Web.UI.Page     {                     protected void Page_Load(object sender, EventArgs e)         {             int x = 0;             try             {                 if(Session["cnt"]==null)                 {                     x = 0;         ...

Display all procedure names of a database schema into treeview

Below is the project which shows all the existing procedure names in any particular database schema into a tree-view control. We have used a class library "stored_proc_db_disp_dll" and imported it's reference into a windows project. The class library contains a function "DisplayProcedures()" which returns a list collection containing all procedure names of a database schema and windows project binds that list to tree-view control. Below is the design view of the project:                             Tree-view displaying all procedure names of a db schema Here is code for class library: namespace stored_proc_db_disp_dll {     public class Class1     {         MySqlConnection con = new MySqlConnection("server=localhost;uid=root;pwd=root;database=test");         MySqlCommand cmd=null;         MySqlDataReader dr; publ...

Treeview control showing all table names in a database schema

Below is the project which shows all the existing table names in any particular database schema into a tree-view control. We have used a class library "stored_proc_db_disp_dll" and imported it's reference into a windows project. The class library contains a function "DisplayTables()" which returns a list collection containing all table names of a database schema and windows project binds that list to tree-view control. Below is the design view of the project: Tree-view displaying all table names of a schema Here is code for class library: namespace stored_proc_db_disp_dll {     public class Class1     {         MySqlConnection con = new MySqlConnection("server=localhost;uid=root;pwd=root;database=test");         MySqlCommand cmd=null;         MySqlDataReader dr; public List DisplayTables()         {             DataTable dt = new Da...

Login in C# using mysql

Below is the c# project which shows how to implement login functionlity using mysql database as backend. Design view of the project: Login Screen Source of the project: using System.Windows.Forms; using MySql.Data.MySqlClient; namespace WindowsFormsApplication1 {     public partial class Form1 : Form     {         MySqlConnection con = new MySqlConnection("server=localhost;uid=root;pwd=root;database=test");         MySqlCommand cmd;         MySqlDataReader dr;                         public Form1()         {             InitializeComponent();             cmd = new MySqlCommand();             cmd.Connection = con;             try             {  ...

create stoared procedure in C#

Following is the project in C# which creates a stoared procedure in mysql database. for that we created a class library and we import this in one windows project. using MySql.Data.MySqlClient; using System.Data; namespace stored_proc_db_disp_dll {     public class Class1     {         MySqlConnection con = new MySqlConnection("server=localhost;uid=root;pwd=root;database=test");         MySqlCommand cmd=null;         MySqlDataReader dr;         public Boolean createprocedure(String str)         {             bool b = true;             try             {                 cmd.CommandText = str;                 cmd.ExecuteNonQuery();             } ...