Saturday, August 31, 2013

Could not load file or assembly 'file:///C:\Program Files\SAP BusinessObjects\Crystal Reports for .NET Framework 4.0\Common\SAP BusinessObjects Enterprise XI 4.0\win32_x86\dotnet1\crdb_adoplus.dll' or one of its dependencies. The system cannot find the file specified.

changing in app.config
 
from:
 
<!--<startup>
  <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup>-->
 
to:
 
<startup useLegacyV2RuntimeActivationPolicy="true">
 
    <supportedRuntime version="v4.0"/>
 
  </startup>

Friday, August 23, 2013

Change mdi parant back color in C#

Here is the code :- 
------------------

Copy and paste this code in form load event.

  foreach (Control c in this.Controls)
            {
                if( c is MdiClient)
                c.BackColor = Color.Red;
            }

Friday, August 9, 2013

How to develop crystal report in windows form c#

how to develop crystal report in window form c#.
here is the link.

http://csharp.net-informations.com/crystal-reports/csharp-crystal-reports-stepbystep.htm

Tuesday, July 16, 2013

Generating Serial Number Inside Gridview with Pagingin asp.net

<asp:TemplateField HeaderText="SNo">

<HeaderStyle CssClass="DetailsContent" />
<ItemStyle Width="6%" Height="18px"  HorizontalAlign="Center" CssClass="DetailsContent"></ItemStyle>
<ItemTemplate>
                         
</ItemTemplate>
</asp:TemplateField>


// Code in Gridview_RowdataBound    protected void gvUserList_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            e.Row.Cells[0].Text = "" + ((((GridView)sender).PageIndex * ((GridView)sender).PageSize) + (e.Row.RowIndex + 1));
        
        }

    }

Thursday, July 11, 2013

METHOD OVERLOADING IN C#.

//Method Overloding :
//The Methods having the same name .. but different signature
//Signature : Number of parameters and Types of parameters
//Return type is not included in signature..
//Return type change : not overloding ...erororororo
class a
{
    //private attribute
    int x;
    public void display()
    {
        x=9999;
        System.Console.WriteLine("x="+x);
    }
    /* erorororororooror
    public int display()
    {
        x=9999;
        System.Console.WriteLine("x="+x);
        return 999;
    }
    */
    public void display(int p)
    {
        x=p;
        System.Console.WriteLine("x="+x);
    }
    public void display(int p,int q)
    {
        x=p+q;
        System.Console.WriteLine("x="+x);
    }
}
class b
{
    public static void Main()
    {
        a z=new a();
        z.display();
        z.display(222);
        z.display(33,33);
       
    }
}


Drop whole database tables using single query

use following query : -
==================


use master

exec sp_MSforeachtable @Command1 = "DROP TABLE ?"

your whole database dables will drop instantly.

Monday, July 8, 2013

Table Variable in SQL

 Table Variable

 Temporary table is the Table variable which can do all kinds of operations that we can perform inTemp table. Below is the syntax for using Table variable.

Declare @TempTableVariable TABLE(
UserID int,
UserName varchar(50), 
UserAddress varchar(150))
The below scripts are used to insert and read the records for Tablevariables:
insert into @TempTableVariable values ( 1, 'Anna','Paris');
Now select records from that tablevariable:
select * from @TempTableVariable

When to Use Table Variable Over Temp Table

Tablevariable is always useful for less data. If the result set returns a large number of records, we need to go for temp table.

Temporary Tables in SQL

  • Introduction
  • Types of Temporary Tables
    • Local Temp Table
    • Global Temp Table
  • Creating Temporary Table in SQL Server
  • Storage Location of Temporary Table
  • When to Use Temporary Tables?

Introduction

SQL Server provides the concept of temporary table which helps the developer in a great way. These tables can be created at runtime and can do the all kinds of operations that one normal table can do. But, based on the table types, the scope is limited. These tables are created inside tempdb database.

Types of Temporary Tables

SQL Server provides two types of temp tables based on the behavior and scope of the table. These are:
  • Local Temp Table
  • Global Temp Table

Local Temp Table

Local temp tables are only available to the current connection for the user; and they are automatically deleted when the user disconnects from instances. Local temporary table name is stared with hash ("#") sign.

Global Temp Table

Global Temporary tables name starts with a double hash ("##"). Once this table has been created by a connection, like a permanent table it is then available to any user by any connection. It can only be deleted once all connections have been closed.

Creating Temporary Table in SQL Server

As I have already discussed, there are two types of temporary tables available. Here I am going to describe each of them.

Local Temporary Table

The syntax given below is used to create a local Temp table in SQL Server :

CREATE TABLE #LocalTempTable(
UserID int,
UserName varchar(50), 
UserAddress varchar(150))

The above script will create a temporary table in tempdb database. We can insert or delete records in thetemporary table similar to a general table like:

insert into #LocalTempTable values ( 1, 'anna','Paris');
Now select records from that table:
select * from #LocalTempTable
After execution of all these statements, if you close the query window and again execute "Insert" or "Select"Command, it will throw the following error:
Msg 208, Level 16, State 0, Line 1
Invalid object name '#LocalTempTable'.
This is because the scope of Local Temporary table is only bounded with the current connection of current user.

Global Temporary Table

The scope of Global temporary table is the same for the entire user for a particular connection. We need to put "##"with the name of Global temporary tables. Below is the syntax for creating a Global Temporary Table:  
CREATE TABLE ##NewGlobalTempTable(
UserID int,
UserName varchar(50), 
UserAddress varchar(150))
The above script will create a temporary table in tempdb database. We can insert or delete records in thetemporary table similar to a general table like:
insert into ##NewGlobalTempTable values ( 1, 'ANNA','Paris');
Now select records from that table:
select * from ##NewGlobalTempTable
Global temporary tables are visible to all SQL Server connections. When you create one of these, all the users can see it.

Storage Location of Temporary Table



When to Use Temporary Tables?

Below are the scenarios where we can use temporary tables:
  • When we are doing large number of row manipulation in stored procedures.
  • This is useful to replace the cursor. We can store the result set data into a temp table, then we can manipulate the data from there.
  • When we are having a complex join operation.

Wednesday, July 3, 2013

How to convert Text to Speech in C#



Steps :
=====

1. Add reference from .NET assembly named System.speech
2 Add code given below in .cs page of the form.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Speech.Synthesis;
using System.IO;
namespace WindowsFormsApplication2
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        SpeechSynthesizer reader; //declare the object
        private void Form1_Load(object sender, EventArgs e)
        {
            reader = new SpeechSynthesizer(); //create new object
         
            textBox1.ScrollBars = ScrollBars.Both;
        }

        private void button1_Click(object sender, EventArgs e)
        {
            reader.Dispose();
            if (textBox1.Text != "")    //if text area is not empty
            {

                reader = new SpeechSynthesizer();
                reader.SpeakAsync(textBox1.Text);
              //  reader.SpeakCompleted += new EventHandler<SpeakCompletedEventArgs>(reader_SpeakCompleted);
            }
            else
            {
                MessageBox.Show("Please enter some text in the textbox", "Message", MessageBoxButtons.OK);
            }
        }

        //event handler
        void reader_SpeakCompleted(object sender, SpeakCompletedEventArgs e)
        {
            label1.Text = "IDLE";
        }
    }
}

Tuesday, July 2, 2013

How to get exe version in window application in C#

Here is the simple line :
================


 string AppVersion = Application.ProductVersion;  //To get Product Version

 string AppVersion = Application.ProductName;    // To get Product Name.

Set value in Text Object in Crystal report at Runtime in C#

Here is the Simple Code :-
===================

CrystalReport1 Obj = new CrysralReport1();

 //Set a Crystal Reports text object at runtime
 CrystalDecisions.CrystalReports.Engine.TextObject txtQuotationNum = ((CrystalDecisions.CrystalReports.Engine.TextObject)crQuotation.ReportDefinition.Sections["Section1"]
.ReportObjects["txtQuotation"]);  // "txtQuotation" is the TextObject name mention on Crystal Report Viewer.

  txtQuotationNum.Text = "bla bla bla...";
  crystalReportViewer1.ReportSource = crQuotation;

Monday, July 1, 2013

DataTable already belongs to another DataSet Exception

Exception Occure : DataTable already belongs to another DataSet Exception :-
--------------------------------------------------------------------------------



Like the other responses point out, the error you're seeing is because the DataTable you're attempting to add to a DataSet is already a part of a different DataSet.

One solution is to Copy the DataTable and assign the copy to the other DataSet.

dataTable dtCopy = datatable1.Copy();
ds.Tables.Add(dtCopy);
Your problem will solve.

Thursday, June 27, 2013

Windows 8 blogger Tamplate for free download

Download Menubar CSS free

Here is the link:
-------------------

http://cssmenumaker.com/css-drop-down-menu

SEO On Blogger


Go to Template--> Edit HTML-->Click

press (ctrl+f)  in code and find this text.
 <title><data:blog.pageTitle/></title>


Replace this text with this text :

<b:if cond='data:blog.pageType == "item"'>
<title><data:blog.pageName/> |<data:blog.title/></title>
<b:else/>
<title><data:blog.pageTitle/></title> </b:if>


you have done...!!!!

Sql Server 2008 Installation Steps

How to insall SQL SERVER 2008 Step by step:-
-------------------------------------------------

Here is the link :

http://blog.sqlauthority.com/2008/06/12/sql-server-2008-step-by-step-installation-guide-with-images/

Download Crystal Report Setup file for Visual Studio 2010 (Developer edition)

Click on the First link for Standard version. This version can install in your system and you can start crystal report. (Developer edition).

https://www.sap.com/campaign/ne/free_trial/crystal_reports_visual_studio/wty_int_crvs.epx?Level=1&FormResultID=91c2d627-6436-443b-9be2-64559651bba8&ContinueURL=%2fcampaign%2fne%2ffree_trial%2fcrystal_reports_visual_studio%2findex.epx%3furl_id%3dtext-na-sapcom-crvs-trial-landing%26kNtBzmUK9zU%3d1&kNtBzmUK9zU=1



for Client edition, so that your application can run on client machine and client can able to print crystal report on his machine.
click on this link.

click "13_0.msm" in MSM 32 bit column on this page.
http://scn.sap.com/docs/DOC-7824

Allow Only Number and single dot C#

//Write code on Textbox KeyPress Event.
=============================


  private void txtQty_KeyPress(object sender, KeyPressEventArgs e)
        {
         
            if (e.KeyChar == '0' || e.KeyChar == '1' || e.KeyChar == '2' || e.KeyChar == '3' || e.KeyChar == '4' || e.KeyChar == '5' || e.KeyChar == '6' || e.KeyChar == '7' || e.KeyChar == '9' || e.KeyChar == '8' || e.KeyChar == '.')
            {
                if (txtQty.Text.ToString().Contains(".") || e.KeyChar == '.')
                {
                    if (txtQty.Text.ToString().Contains(".") && e.KeyChar == '.')
                    {
                        e.Handled = true;
                    }

                    else
                    {
                        e.Handled = false;
                    }
                }
            }
            else if (e.KeyChar == '\b')
            {
                e.Handled = false;
            }
            else
            {
                e.Handled = true;
            }

         
        }

Thursday, June 20, 2013

How to get all text in uppercase latters in a textbox using java script in asp.net

use this script in header section :-
--------------------------------

<script type="text/javascript">
        function ToUpper(txt) {
            document.getElementById(txt).value = document.getElementById(txt).value.toUpperCase();
        }
</script>



Take a textbox like this and call the java script function over here. :-
-------------------------------------------------------------------

<asp:TextBox ID="txtCode" runat="server" AutoPostBack="True"
                             ontextchanged="txtCode_TextChanged" MaxLength="99"  onkeypress="ToUpper(this.id)" onblur="ToUpper(this.id)"></asp:TextBox>

Friday, May 17, 2013

How to passing the value from One form to another form in windows application c#

 Write code on Form -1 :--
=======================

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            Form2 objForm2 = new Form2(this);
            objForm2.Show();

        }

      public void PassValue(string strValue)
    {
        textBox1.Text = strValue;
    }


    }
}
------------------------------------------------------------------------------------------------------------


Write code on form : 2:-
=====================
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace WindowsFormsApplication1
{
    public partial class Form2 : Form
    {
        Form1 ownerForm = null;
        public Form2()
        {
            InitializeComponent();
        }
        public Form2(Form1 ownerForm)            //create parameterized  constructor for form 1
        {
            InitializeComponent();
            this.ownerForm = ownerForm;
        }
        private void Form2_Load(object sender, EventArgs e)
        {
        
        }

      

        private void button1_Click(object sender, EventArgs e)
        {
            this.ownerForm.PassValue(textBox1.Text);
            this.Close();
        }
    }
}


Sunday, April 21, 2013

How to get Network Adapter Mac Address in C#


 

First you need to add refererense from for get the mac address of network adapter.
Add Reference -->  .NET --> System.Management.

----------------------------*****************--------------------------
To get mac address of Local system.
using System.Managemant;
public static string GetMacAddress()
            {
                string Mac = string.Empty;
                ManagementClass MC = new ManagementClass("Win32_NetworkAdapter");
                ManagementObjectCollection MOCol = MC.GetInstances();
                foreach (ManagementObject MO in MOCol)
                    if (MO != null)
                    {
                        if (MO["MacAddress"] != null)
                        {
                            Mac = MO["MACAddress"].ToString();
                            if (Mac != string.Empty)
                                break;
                        }
                    }
                return Mac;
            }

-------------------------------------------------------------------------------

To get mac address of when your system in on LAN on etharnet .

Using System.Management;

  public PhysicalAddress GetMacAddress()           //Get MAC Address of the machine.
        {
            foreach (NetworkInterface nic in NetworkInterface.GetAllNetworkInterfaces())
            {
                // Only consider Ethernet network interfaces
                if (nic.NetworkInterfaceType == NetworkInterfaceType.Ethernet &&
                    nic.OperationalStatus == OperationalStatus.Up)
                {
                    return nic.GetPhysicalAddress();
                }
            }
            return null;
        }