Google Mobile Ads

Wednesday, July 18, 2012

VB.Net'te Datatable'ı Excel'e Aktaran Metod

VB.Net'te Excel Interop kullanarak bir datatable ın Excel'e aktarılmasını sağlayan metodumuz aşağıdaki gibidir. Metodu kullanabilmeniz için projenize Microsoft.Office.Interop.Excel referansını eklemeniz gerekmektedir.


    Private Sub DatatableToExcel(ByVal dtTemp As DataTable)
        Try
            Dim myCultureInfo As CultureInfo = System.Threading.Thread.CurrentThread.CurrentCulture
            Dim _excel As New Microsoft.Office.Interop.Excel.Application
            Dim wBook As Microsoft.Office.Interop.Excel.Workbook
            Dim wSheet As Microsoft.Office.Interop.Excel.Worksheet


            folderBrowser.ShowDialog()
            If folderBrowser.SelectedPath <> "" Then
                System.Threading.Thread.CurrentThread.CurrentCulture = New System.Globalization.CultureInfo("en-us")
                wBook = _excel.Workbooks.Add()
                wSheet = wBook.ActiveSheet()


                Dim dt As System.Data.DataTable = dtTemp
                Dim dc As System.Data.DataColumn
                Dim dr As System.Data.DataRow
                Dim colIndex As Integer = 0
                Dim rowIndex As Integer = 0


                For Each dc In dt.Columns
                    colIndex = colIndex + 1
                    _excel.Cells(1, colIndex) = dc.ColumnName
                Next


                For Each dr In dt.Rows
                    rowIndex = rowIndex + 1
                    colIndex = 0
                    For Each dc In dt.Columns
                        colIndex = colIndex + 1
                        _excel.Cells(rowIndex + 1, colIndex) = dr(dc.ColumnName)
                    Next
                Next


                wSheet.Columns.AutoFit()
                Dim strFilePath As String = folderBrowser.SelectedPath + "\"
                Dim strFileName As String = "Sorgu_" + Date.Now.Year.ToString() + Date.Now.Month.ToString() + Date.Now.Day.ToString() + Date.Now.Second.ToString() + ".xlsx"
                If System.IO.File.Exists(strFilePath + strFileName) Then
                    System.IO.File.Delete(strFilePath + strFileName)
                End If


                wBook.SaveAs(strFilePath + strFileName)
                wBook.Close()
                _excel.Quit()


                System.Threading.Thread.CurrentThread.CurrentCulture = myCultureInfo
                MsgBox("Sorgu Sonuç Ekranı Excel'e Aktarılmıştır." + vbCrLf + "Dosyanın Kaydedildiği Yol: " + strFilePath + vbCrLf + "Dosya Adı: " + strFileName)
            End If
        Catch ex As Exception


        End Try
    End Sub

Tuesday, June 26, 2012

"No template information found. See the application log in Event Viewer for more details." Error Message

http://blog.laksha.net/2008/09/no-visual-studio-template-information.html?showComment=1234405860000


I am facing the following issue in my Visual Studio 2008. When I try to Create new website or new project it shows following error message.
“No template information found. See the application log in Event Viewer for more details.
To open Event Viewer, click Start, Click Control Panel, double-click Administrative Tools, and then double-click Event Viewer.”
image

SSIS 'de Execute SQL Task ile sql ifadesinden gelen result 'ı bir variable a assign ederken karşılaşılan bir problem : VARCHAR(MAX)

[Execute SQL Task] Error: An error occurred while assigning a value to variable "ColumnName": "The type of the value being assigned to variable "User::varColumnName" differs from the current variable type. Variables may not change type during execution. Variable types are strict, except for variables of type Object!."


SQL İfadesi : SELECT ColumnName FROM MyTableName


Sql ifadesinde kullandığım Varchar(max) değeri döndüren result kolonunu(ColumnName), SSIS'deki string değişkenine atamaya çalışırken yukarıdaki hata ile karşılaştım.

Çözümü şu şekide:

SSIS'de string değişkene, SQL Server'daki Max değerli bir varchar veya nvarchar veri tipi atanamadığı için, SQL ifadesindeki ColumnName isimli varchar(max) veri tipine sahip kolonu varchar(1000) gibi bir limite cast etmemiz gerekmektedir.


SELECT CAST(ColumnName AS VARCHAR(1000)) AS ColumnName FROM MyTableName

Thursday, June 21, 2012

SQL Server'da Bir Tabloya Ait Kolon İsimlerini Öğrenmek

SELECT name
FROM   syscolumns
WHERE  id = (SELECT id FROM sysobjects WHERE name='TableName')


* How to find out column names of a table in SQL Server

Wednesday, June 20, 2012

SQL Server'da Bir Tabloya Ait Kolon Veri Tiplerini Öğrenmek

DECLARE @Table_Name NVARCHAR(100)
SET @Table_Name = 'mytablename'


SELECT object_name(c.id)    AS table_name, 
c.name               AS column_name,
t.name              AS data_type
FROM syscolumns AS c 
INNER JOIN systypes   AS t  ON c.xtype = t.xtype
WHERE c.id = object_id( @Table_Name )


* How to find out column data types of a table in SQL Server

Wednesday, June 13, 2012

Data Sources for Xcelsius (Dashboard Design)

  • Business Objects Live Office
  • QaaWS (Query as a Web Service)
  • Web Services
  • SAP Netweaver BW
  • XML Data
  • FS Command
  • Flash Variables
  • Adobe LCDS
  • MS Excel Maps

LinkWithin

Related Posts Plugin for WordPress, Blogger...