Posts

Retrieve (Get) data from Database using Web Mehthod in asp.net

Image
Retrieve (Get) data from Database using Web Mehthod in asp.net   pagename.aspx   pagename.aspx.cs using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.IO; using System.Data; using System.Data.SqlClient; using System.Web.Services; public partial class Multiplefileuploader : System.Web.UI.Page {     protected void Page_Load(object sender, EventArgs e)     {         if (!Page.IsPostBack)         {             Getselect_tbl();         }     }     protected void UploadMultipleFiles(object sender, EventArgs e)     {     }     [WebMethod]     public static List Getselect_tbl()     { ...

Connection with M S Excel using asp.net

Connection with M S Excel file (which is type (.xlsx)) (C#) asp.net  Connection :  OleDbConnection conn = new OleDbConnection ( @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\nitin\Desktop\db_sumit.xlsx;Extended Properties=Excel 12.0 Xml" );   Select Query :       private void ConnectionExcel()     {         OleDbDataAdapter adp = new OleDbDataAdapter ( "Select * from [Sheet1$]" , conn);         DataTable dt = new DataTable ();         adp.Fill(dt);         GridView2.DataSource = dt;         GridView2.DataBind();     } InsertQuery : private void Insertwithaccess()     {         int IsCount = 0;         string cmdquery = "Insert into [ Sheet...

Connection with M S Access using asp.net

Connection with M S Access file (which is type (.accdb)) (C#) asp.net 1. Add namespace. Ans: using System.Data.OleDb; ------ end 2. add Connection. Ans: private void Connection()     {         OleDbConnection con = new OleDbConnection ( @"Provider = Microsoft.ACE.OLEDB.12.0;Data Source = C:\Users\nitin\Desktop\db_testing.accdb;" );         OleDbDataAdapter adp = new OleDbDataAdapter ( "Select*from table1" , con);         DataTable dt = new DataTable ();         adp.Fill(dt);         GridView1.DataSource = dt;         GridView1.DataBind();     } ------ end   Inserting :     private void Insertwithaccess()     {         int IsCount = 0;   ...
How to "Change column name" in Sql server 2008 Ans : 1.  sp_rename 'Tbl_Enquiry.[old_column_name]','New_column_name'  (select this line and run (f5)) 2. sp_RENAME 'Table_First . Name', ' NameChange ' , 'COLUMN'.
  How To Get IP Address (c#) using asp.net _______________________________ start _______________________________               string address = string .Empty;         address = Dns .GetHostName();         IPAddress [] localip = Dns .GetHostAddresses( Dns .GetHostName());         foreach ( IPAddress hostIP in localip)         {             address = hostIP.ToString();         } _______________________________ end _______________________________  result : address : XXX.XXX.X.XX

Count String using C#

Count space int countSpaces = mystring . Count ( Char . IsWhiteSpace ); Count Character in a string static int CountChars (string value) { int result = 0; bool lastWasSpace = false; foreach (char c in value) { if (char.IsWhiteSpace(c)) { // A. // Only count sequential spaces one time. if (lastWasSpace == false) { result++; } lastWasSpace = true; } else { // B. // Count other characters every time. result++; lastWasSpace = false; } } return result; }     counts non-whitespace characters.   static int CountNonSpaceChars (string value) { int result = 0; foreach (char c in value) { if (!char.IsWhiteSpace(c)) { result++; } } return result; }    

UPDATE TRIGGER ON TABLE

Trigger are three types : INSERT, UPDATE, DELETE and trigger have two magic table  INSERTED and DELETED...  when we execute DML (INSERT, UPDATE, DELETE) operation then trigger is automatically execute. example : I have three table INWARD , OUTWARD  and ALLTYPESTOCK OK. so when i insert data in "inward" table then data insert not only inward but also in "alltypestock" table. and same situation with outward...  SO task is data of both table is store in ALLTYPESTOCK table, when i want to chage(update)  any data  of alltypestock then automatically data update which came form the table . UPDATE TRIGGER:                                                                  ------------------- INWARDSTOCK                       ...