Tuesday, November 29, 2011 | | 0 comments

How to image insert to database

1.first add to button this button name is browse and
add to picture box this name is pcimg 

2.now brwose the image and load to image in picture box...coding is 




OpenFileDialog open = new OpenFileDialog();


            open.Filter = "Image Files(*.jpg; *.jpeg; *.gif; *.bmp)|*.jpg; *.jpeg; *.gif; *.bmp";
           if (open.ShowDialog() == DialogResult.OK)


            {
               Image img = new Bitmap(open.FileName);
                pcimg.Image = img.GetThumbnailImage(340, 165, null, new IntPtr());
                open.RestoreDirectory = true;
                Image thumbimage = pcimg.Image;
                pcimg.Image = thumbimage.GetThumbnailImage(100, 100, null, new IntPtr());


            }


3.now image convert to the byte.we can using filestream or MemoryStream..memory stream is better than filestream .......coding is 


                             byte[] emp_photo;                           
                             MemoryStream ms = new MemoryStream();
                             pcimg.Image.Save(ms, ImageFormat.Jpeg);
                             emp_photo = new byte[ms.Length];
                             ms.Position = 0;
                              ms.Read(emp_photo, 0, emp_photo.Length);


4.now add image to sql data base....image sql datatype is image
coding is
 
                            SqlParameter pm = new SqlParameter("@logo", SqlDbType.Image);
                            pm.Value = emp_photo;
                            cmd.Parameters.Add(pm);
                            cmd.ExecuteNonQuery();


| | 0 comments

How to Clear all textbox field in one form...?

mostly we are using in asp.net page redirect same page or using null values in each textbox.text... 

now i am using simple way ....get all textboxes in single textbox array and run the loop for example coding is..... 

public void empty()
        {
            TextBox[] textempty = { txtcategoryname, txtshortcode, txtdescription };
            for (int i = 0; i < textempty.Length; i++)
            {
                textempty.Text = string.Empty;
            }
        }

| | 0 comments

How to Get System name through C#

First using Namespace 
using System.Security.Principal;


and then 

Process.Start("C:\\Documents and Settings\\"+WindowsIdentity.GetCurrent().Name.Split('\\')[1]+ "\\My Documents\\Company Details.xls ");

Monday, August 29, 2011 | | 0 comments

Ajax Control Tool kit3.5,4.0

Ajax toolkit Samples:   Click Here

Download Ajax Toolkit for 3.5,4.0:  Click Here

Tuesday, July 19, 2011 | | 0 comments

UNABLE TO CONNECT TO ASP.NET DEVELOPMENT SERVER

sometimes during debugging of our website code..we get a message
unable to connect to asp.net sever
here is a trick to resolve it
first download the file from following link
http://www.ziddu.com/download/13699026/WebDev.WebServer.rar.htmlextract the file ..
u will get an exe named WebDev.WebServer.exe
simply right click and copy it..
now..
goto your drive containing windows...
by deault this is c drive..
so open
the following path...
C:\Program Files\Common Files\microsoft shared\DevServer\9.0
you will find already a file named WebDev.WebServer.exe..
so what you have to do is simply replace this file...
by right click and paste...
and click yes on the message that you want to replace the file..
yes its done ...

Sunday, April 24, 2011 | | 1 comments

Download e-books




  • Complete Reference Books - SQL Server 2005




  • Wrox Beginning Tutorial Ebooks - ActionScript 2.0.pdf




  • Wrox Beginning Tutorial Ebooks - ASP.NET 2.0 with C#.pdf




  • Wrox Beginning Tutorial Ebooks - C Sharp - Introduction to Object Oriented Programming.pdf




  • Wrox Beginning Tutorial Ebooks - CSS for Web Design.pdf




  • Software Ebooks Bible Series - ActionScript 3.0.pdf




  • Software Ebooks Bible Series - ASP.NET.pdf



  • Sams Teach Yourself Series - ADO.NET in 24 Hours




  • OReilly Books Series - ASP in a Nutshell





  • Sams Teach Yourself Series - JavaScript 1.1.pdf




  • Manning In Action Series - ASP.Net Webparts.pdf




  • Head First - C#.part1





  • Head First - C#.part2




  • Dummies Books Series - ASP.NET 2.0 AIO Reference.pdf




  • Dummies Books Series - ASP.NET 2.0 Everyday Apps.pdf




  • Dummies Books Series - ASP.NET 3.5.pdf




  • Dummies Books Series - CSS Web Design.pdf





  • Friday, April 22, 2011 | | 0 comments

    Scrollbar in gridview

    <div style="OVERFLOW: auto; WIDTH: 800px; HEIGHT: 240px">

    gidview



    </div>

    Thursday, April 21, 2011 | | 0 comments

    How to export databse to excel file


    using System;
    using System.Windows.Forms;
    using System.Data;
    using System.Data.SqlClient;
    using Excel = Microsoft.Office.Interop.Excel; 
    
    namespace WindowsApplication1
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
            }
    
            private void button1_Click(object sender, EventArgs e)
            {
                SqlConnection cnn ;
                string connectionString = null;
                string sql = null;
                string data = null;
                int i = 0;
                int j = 0; 
    
                Excel.Application xlApp ;
                Excel.Workbook xlWorkBook ;
                Excel.Worksheet xlWorkSheet ;
                object misValue = System.Reflection.Missing.Value;
    
                xlApp = new Excel.ApplicationClass();
                xlWorkBook = xlApp.Workbooks.Add(misValue);
                xlWorkSheet = (Excel.Worksheet)xlWorkBook.Worksheets.get_Item(1);
    
                connectionString = "data source=servername;initial catalog=databasename;user id=username;password=password;";
                cnn = new SqlConnection(connectionString);
                cnn.Open();
                sql = "SELECT * FROM Product";
                SqlDataAdapter dscmd = new SqlDataAdapter(sql, cnn);
                DataSet ds = new DataSet();
                dscmd.Fill(ds);
    
                for (i = 0; i <= ds.Tables[0].Rows.Count - 1; i++)
                {
                    for (j = 0; j <= ds.Tables[0].Columns.Count - 1; j++)
                    {
                        data = ds.Tables[0].Rows[i].ItemArray[j].ToString();
                        xlWorkSheet.Cells[i + 1, j + 1] = data;
                    }
                }
    
                xlWorkBook.SaveAs("csharp.net-informations.xls", Excel.XlFileFormat.xlWorkbookNormal, misValue, misValue, misValue, misValue, Excel.XlSaveAsAccessMode.xlExclusive, misValue, misValue, misValue, misValue, misValue);
                xlWorkBook.Close(true, misValue, misValue);
                xlApp.Quit();
    
                releaseObject(xlWorkSheet);
                releaseObject(xlWorkBook);
                releaseObject(xlApp);
    
                MessageBox.Show("Excel file created , you can find the file c:\\csharp.net-informations.xls");
            }
    
            private void releaseObject(object obj)
            {
                try
                {
                    System.Runtime.InteropServices.Marshal.ReleaseComObject(obj);
                    obj = null;
                }
                catch (Exception ex)
                {
                    obj = null;
                    MessageBox.Show("Exception Occured while releasing object " + ex.ToString());
                }
                finally
                {
                    GC.Collect();
                }
            }
    
        }
    }

    | | 0 comments

    Crystal Reports( Button Click)

    Header File


    using CrystalDecisions.CrystalReports.Engine;


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



    protected void Button1_Click(object sender, EventArgs e)
        {
            ReportDocument cryRpt = new ReportDocument();
            cryRpt.Load("E:\\crystelreport\\CrystalReport.rpt");
            CrystalReportViewer1.ReportSource = cryRpt;
            CrystalReportViewer1.RefreshReport();
        }

    | | 0 comments

    Crystal Reports in ASP.NET



    Crystal Reports in ASP.NET
    Crystal Reports is the standard reporting tool for Visual Studio .NET used to display data of presentation quality. You can display multiple-level totals, charts to analyze data, and much more in Crystal Reports. Creating a Crystal Report requires minimal coding since it is created in Designer interface. It is available as an integrated feature of Microsoft Visual Studio .NET, Borland Delphi, and C#Builder.
    Advantages of Crystal Reports
    Some of the major advantages of using Crystal Reports are:
    1. Rapid report development since the designer interface would ease the coding work for the programmer.
    2. Can extend it to complicated reports with interactive charts and enhance the understanding of the business model
    3. Exposes a report object model, can interact with other controls on the ASP.NET Web form
    4. Can programmatically export the reports into widely used formats like .pdf, .doc, .xls, .html and .rtf
    Implementation Models
    Crystal Reports need database drivers to connect to the data source for accessing data. Crystal Reports in .net support two methods to access data from a data source:
    The Pull Method
    When this model is used to access data from the data source, the database driver directly retrieves the data from the data source. This model does not require the developer to write code for creating a connection and retrieving data from the data source. It is the Crystal report that manages the SQL commands for connecting by using the specified driver.

    The Push Method
    When this model is used to access data from data source, the developer writes the code to connect to the data source and retrieve data. The data from the data source is cached in dataset and multiple crystal reports accesses data from the dataset. The performance can be optimized in this manner by using connection sharing and manually limiting the number of records that are passed on to the report.
                                                 

    Crystal Reports Types
    Crystal Report Designer can load reports that are included into the project as well as those that are independent of the project.
    Strongly-typed Report
    When you add a report file into the project, it becomes a "strongly-typed" report. In this case, you will have the advantage of directly creating an instance of the report object, which could reduce a few lines of code, and cache it to improve performance. The related .vb file, which is hidden, can be viewed using the editor's "show all files" icon in the Solution Explorer.
    Un-Typed Report
    Those reports that are not included into the project are "un-typed" reports. In this case, you will have to create an instance of the Crystal Report Engine's "ReportDocument" object and manually load the report into it.
    Creating Crystal Reports
    You can create a Crystal Report by using three methods:
    1. Manually i.e. from a blank document
    2. Using Standard Report Expert
    3. From an existing report
    Using Pull Method
    Creating Crystal Reports Manually.
    We would use the following steps to implement Crystal Reports using the Pull Model:
    1. Create the .rpt file (from scratch) and set the necessary database connections using the Crystal Report Designer interface.
    2. Place a CrystalReportViewer control from the toolbox on the .aspx page and set its properties to point to the .rpt file that we created in the previous step.
    3. Call the databind method from your code behind page.
    I. Steps to create the report i.e. the .rpt file
    1) Add a new Crystal Report to the web form by right clicking on the "Solution Explorer", selecting "Add" --> "Add New Item" --> "Crystal Report".

    2) On the "Crystal Report Gallery" pop up, select the "As a Blank Report" radio button and click "ok".

    3) This should open up the Report File in the Crystal Report Designer.

    4) Right click on the "Details Section" of the report, and select "Database" -> "Add/Remove Database".
    5) In the "Database Expert" pop up window, expand the "OLE DB (ADO)" option by clicking the "+" sign, which should bring up another "OLE DB (ADO)" pop up.
    6) In the "OLE DB (ADO)" pop up, Select "Microsoft OLE DB Provider for SQL Server" and click Next.

    7) Specify the connection information.
    8) Click "Next" and then click "Finish"
    9) Now you should be able to see the Database Expert showing the table that have been selected
    10) Expand the "Pubs" database, expand the "Tables", select the "Stores" table and click on ">" to include it into the "Selected Tables" section.
    Note: If you add more than one table in the database Expert and the added tables have matching fields, when you click the OK button after adding the tables, the links between the added tables is displayed under the Links tab. You can remove the link by clicking the Clear Links button.

    11) Now the Field Explorer should show you the selected table and its fields under the "Database Fields" section, in the left window.
    12) Drag and drop the required fields into the "Details" section of the report. The field names would automatically appear in the "Page Header" section of the report. If you want to modify the header text then right click on the text of the "Page Header" section, select "Edit Text Object" option and edit it.

    13) Save it and we are through.

    Tuesday, April 19, 2011 | | 0 comments

    Add and Download Ajax extension Control And Ajax control Toolkit for Asp.net 2.0/1.0/3.5

    Saturday, April 16, 2011 | | 0 comments

    how to call connection string from web config file.?


    <configuration>
    <appSettings/>
    <connectionStrings>
      <add name="sunrockConnectionString" connectionString="Data Source=WINXP_PC\SQLEXPRESS;Initial Catalog=sunrock;Integrated Security=True"
       providerName="System.Data.SqlClient" />
     
     </connectionStrings>
    <system.web>

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

    cn.ConnectionString = ConfigurationManager.ConnectionStrings["sunrockConnectionString"].ToString();
            cn.Open();

    | | 0 comments

    Dropdown onclick ,change items of another dropdown


    using System;
    using System.Data;
    using System.Configuration;
    using System.Collections;
    using System.Web;
    using System.Web.Security;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
    using System.Web.UI.HtmlControls;
    using System.Data.SqlClient;

    public partial class drop : System.Web.UI.Page
    {
        SqlConnection con = new SqlConnection();
        protected void Page_Load(object sender, EventArgs e)
        {
      
        }
        protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (DropDownList1.SelectedValue== "Tamilnadu")
            {
                this.DropDownList2.Items.Clear();
                this.DropDownList2.Items.Add("chennai");
                this.DropDownList2.Items.Add("trichy");
              
            }
            else if (DropDownList1.SelectedValue == "Kerala")
            {
                this.DropDownList2.Items.Clear();
                this.DropDownList2.Items.Add("aaa");
                this.DropDownList2.Items.Add("ccc");

            }
            else
            {
                this.DropDownList2.Items.Clear();
                this.DropDownList2.Items.Add("bbb");
                this.DropDownList2.Items.Add("ddd");
            }
            GridView1.Visible = true;
        }
        protected void DropDownList2_SelectedIndexChanged(object sender, EventArgs e)
        {
     

        }
    }