Posts

Showing posts from 2014

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                       ...

Insert Data in Database (mssql)

Image
How TO Insert Data In MSsql DataBase with ASP.NET (C#). So let's Start Now...  You must do 5 steps for insert, update, and delete (DML)Operations. Step 1: Add " using System.Data.SqlClient ; ". Step 2: Create Object of SqlConnection...  like this..  ( SqlConnection Objname = new SqlConnection(); ) Step 3: Crate Object of SqlCommand.... like this... ( SqlCommand  cmd = new SqlCommannd(); ). Step 4: After create Objects of sqlconnection and sqlcommand You Open the Connection. Like this (Objname.Open() ;) Step 5: Execute your Query... Here Example::::...... -------------------------------------------------------------------------------------------                                                                   Code Start ------------------------------------------------------------------...
This is for beginner...      How to create DATABASE in MSSQL ? CREATE DATABASE databasename      How to use DATABASE in MSSQL ? USE databasename     How to create table in MS-SQL ? CREATE TABLE tablename              (                                                                                    columb_ID INT,                                  column_Name VARCHAR (100),  )                                           ...