Thursday, 2 May 2019

Error while uploading project with chart

<appSettings>
<add key="ChartImageHandler" value="storage=file;timeout=20;Url=~/images/;"/> //change this
    <add key="ChartImageHandler" value="storage=memory;deleteAfterServicing=true;Url=~/images/;"/>
</appSettings>

Thursday, 4 April 2019

Export Excel in VB.Net

Imports System.Data.SqlClient
Imports System.Data.OleDb
Imports System.IO
Imports System.Net.Mime.MediaTypeNames
Imports Microsoft.Office.Interop


Dim idx As Integer
    Private Excel03ConString As String = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source={0};Extended Properties='Excel 8.0;HDR={1}'"
    Private Excel07ConString As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source={0};Extended Properties='Excel 8.0;HDR={1}'"


Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim rowsTotal, colsTotal As Short
        Dim I, j, iC As Short
        System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.WaitCursor
        Dim xlApp As New Excel.Application
        Try
            Dim btn As Button
            Dim excelBook As Excel.Workbook = xlApp.Workbooks.Add
            Dim excelWorksheet As Excel.Worksheet = CType(excelBook.Worksheets(1), Excel.Worksheet)
            xlApp.Visible = True
            Dim chartRange As Excel.Range


            rowsTotal = DataGridView1.RowCount - 1
            colsTotal = DataGridView1.Columns.Count - 1
            chartRange = excelWorksheet.Range("A1", "G1")

            chartRange.HorizontalAlignment = 3
            chartRange.VerticalAlignment = 3
            chartRange.Interior.Color = System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.Yellow)
            chartRange.Font.Color = System.Drawing.ColorTranslator.ToOle(System.Drawing.Color.Red)
            chartRange.Font.Size = 20

            chartRange = excelWorksheet.Range("A1", "G1")
            chartRange.Font.Bold = True
            chartRange = excelWorksheet.Range("A1", "G1")
            chartRange.Font.Bold = True


            chartRange = excelWorksheet.Range("A1", "G1")
            With excelWorksheet
                .Cells.Select()
                .Cells.Delete()

                For iC = 0 To colsTotal


                    .Cells(1, iC + 1).Value = DataGridView1.Columns(iC).HeaderText
                    .Cells(1, iC + 1).ColumnWidth = 20
                    .Cells(1, iC + 1).Font.FontStyle = "Bold"
                    .Cells(1, iC + 1).Font.Size = 15

                Next iC
                For I = 0 To rowsTotal
                    For j = 0 To colsTotal
                        .Cells(I + 2, j + 1).value = DataGridView1.Rows(I).Cells(j).Value

                    Next j
                Next I


                '.Cells.ColumnWidth = 15
                .Cells.Select()
                .Cells.EntireColumn.AutoFit()
                .Cells(1, 1).Select()


            End With



        Catch ex As Exception
            'MsgBox("Export Excel Error " & ex.Message)
        Finally
            'RELEASE ALLOACTED RESOURCES
            System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.Default
            xlApp = Nothing
        End Try
End Sub

Find all the table list in our database

select * from INFORMATION_SCHEMA.TABLES 

Get the first word after a specified string

    Dim sa As String
    Dim s As String
    Dim sp() As String
    sa = TextBox1.Text  //this text box contains value **Open Ended Schemes(Debt Scheme - Banking and PSU Fund)**
    sp = sa.Split("(")  //Here u get the output as **Debt Scheme - Banking and PSU Fund)** which means content after the open bracket...
    sp = sp(1).Split(")")  //Here u get the output as Debt Scheme - Banking and PSU Fund which means content till the close bracket...
    s = Split(sp(0))(0)  //Here it will take the first word, which means u will get the output as **Debt**
    s = Split(sp(0))(1)  //Change the index as per the word u want, here u get the output as **Scheme**

Thursday, 28 March 2019

If u care for others....

  • If you care for your brain - sleep for 8hours
  • If you care for your eyes - massage your feet with oil before going to bed
  • If you care for your stomach - avoid cold food
  • If you care for your liver - avoid excessive fatty food
  • If you care for your intestine - replace junk food with vegetables
  • If you care for your kidney - drink a lot of water during the day
  • If you care for your kidney - drink less water at night
  • If you care for your kidney - empty your bladder before going to bed
  • If you care for your urinary tract - use raw onion regularly
  • If you care for your menstruation - use green gram regularly
  • If you care for your appendix - use lemon juice frequently
  • If you care for your throat - use pepper frequently
  • If you care for your lungs - avoid smoking
  • If you care for your heart - avoid excess salt
  • If you care for your mouth - gargle frequently with gingelly(sesame) oil
  • If you care for your nose - eat mint regularly
  • If you care for your ears - pour garlic mixed oil in ears frequently

How to take backup of a table with data in it

Right click on the database.
select the tables you want to take the backup
Next => Next => Finish
Then you will get a .sql file. When ever you need the data you can execute this file in SQL management studio.

Wednesday, 13 March 2019

Setting Tab in Gridview row wise

protected void Gridview1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            DropDownList ddl = e.Row.FindControl("txtdes") as DropDownList;
            TextBox txt1 = e.Row.FindControl("txtquan") as TextBox;
            TextBox txt2 = e.Row.FindControl("ddlDay") as TextBox;
            TextBox txt3 = e.Row.FindControl("txtTotal") as TextBox;
            int i = e.Row.RowIndex * 4;
            ddl.Attributes.Add("tabindex", (i + 1).ToString());
            txt1.Attributes.Add("tabindex", (i + 2).ToString());
            txt2.Attributes.Add("tabindex", (i + 3).ToString());
            txt3.Attributes.Add("tabindex", (i + 4).ToString());
            if (e.Row.RowIndex == 0)
                ddl.Focus();
        }
    }