Click here to Skip to main content
16,005,080 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: Date formate in VB .net. Pin
jeshra2799-Dec-09 3:43
jeshra2799-Dec-09 3:43 
GeneralRe: Date formate in VB .net. Pin
Luc Pattyn9-Dec-09 3:52
sitebuilderLuc Pattyn9-Dec-09 3:52 
GeneralRe: Date formate in VB .net. Pin
richardw489-Dec-09 6:00
richardw489-Dec-09 6:00 
QuestionRandom Acces file (FileGet QUESTION) [modified] Pin
PAguilar098-Dec-09 20:52
PAguilar098-Dec-09 20:52 
AnswerRe: Random Acces file (FileGet QUESTION) Pin
Dave Kreskowiak9-Dec-09 5:55
mveDave Kreskowiak9-Dec-09 5:55 
GeneralRe: Random Acces file (FileGet QUESTION) Pin
PAguilar099-Dec-09 6:29
PAguilar099-Dec-09 6:29 
GeneralRe: Random Acces file (FileGet QUESTION) Pin
Dave Kreskowiak9-Dec-09 8:03
mveDave Kreskowiak9-Dec-09 8:03 
QuestionBulk insert to excel from vb.net Pin
Uma J8-Dec-09 17:49
Uma J8-Dec-09 17:49 
hi,
pls anyone try to solve my problem... i need to fetch some thousands of records and insert/export that to excel file using vb.net...

Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim cnt As New ADODB.Connection
Dim rst As New ADODB.Recordset

Dim xlApp As Object
Dim xlWb As Object
Dim xlWs As Object


Dim recArray As Object
Dim strDB As String
Dim fldCount As Integer
Dim recCount As Long
Dim iCol As Integer
Dim iRow As Integer

strDB = "UNOGI\UNO;database=Test;uid=sa;pwd=welcome3#" 'here am getting the following error "Could not find installable ISAM."

cnt.Open("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & strDB & ";")
rst.Open("select top 10000 * from Test.dbo.CustomerDetail", cnt)

xlApp = CreateObject("Excel.Application")
xlWb = xlApp.Workbooks.Add
xlWs = xlWb.Worksheets("Sheet1")
xlApp.Visible = True
xlApp.UserControl = True
fldCount = rst.Fields.Count
For iCol = 1 To fldCount
xlWs.Cells(1, iCol).Value = rst.Fields(iCol - 1).Name
Next
If Val(Mid(xlApp.Version, 1, InStr(1, xlApp.Version, ".") - 1)) > 8 Then
xlWs.Cells(2, 1).CopyFromRecordset(rst)

Else
recArray = rst.GetRows
recCount = UBound(recArray, 2) + 1
For iCol = 0 To fldCount - 1
For iRow = 0 To recCount - 1

If IsDate(recArray(iCol, iRow)) Then
recArray(iCol, iRow) = Format(recArray(iCol, iRow))

ElseIf IsArray(recArray(iCol, iRow)) Then
recArray(iCol, iRow) = "Array Field"
End If
Next iRow
Next iCol

' Transpose and Copy the array to the worksheet,
' starting in cell A2
xlWs.Cells(2, 1).Resize(recCount, fldCount).Value = _
TransposeDim(recArray)

End If

' Auto-fit the column widths and row heights
xlApp.Selection.CurrentRegion.Columns.AutoFit()
xlApp.Selection.CurrentRegion.Rows.AutoFit()

' Close ADO objects
rst.Close()
cnt.Close()
rst = Nothing
cnt = Nothing

' Release Excel references
xlWs = Nothing
xlWb = Nothing

xlApp = Nothing

End Sub

Function TransposeDim(ByVal v As Object) As Object
' Custom Function to Transpose a 0-based array (v)

Dim X As Long, Y As Long, Xupper As Long, Yupper As Long
Dim tempArray As Object

Xupper = UBound(v, 2)
Yupper = UBound(v, 1)

ReDim tempArray(Xupper, Yupper)
For X = 0 To Xupper
For Y = 0 To Yupper
tempArray(X, Y) = v(Y, X)
Next Y
Next X

TransposeDim = tempArray
End Function

in the above code i got some error, if anyone knows any other way pls try to help me resolve as soon as you can... thanks in advance..
AnswerRe: Bulk insert to excel from vb.net Pin
_Damian S_8-Dec-09 17:56
professional_Damian S_8-Dec-09 17:56 
GeneralRe: Bulk insert to excel from vb.net Pin
Uma J8-Dec-09 18:08
Uma J8-Dec-09 18:08 
GeneralRe: Bulk insert to excel from vb.net Pin
Dave Kreskowiak9-Dec-09 4:24
mveDave Kreskowiak9-Dec-09 4:24 
AnswerRe: Bulk insert to excel from vb.net Pin
jonesberyl16-Aug-10 20:40
jonesberyl16-Aug-10 20:40 
QuestionApplication.DoEvents() equivalent in aspx Pin
Roger Rainey8-Dec-09 4:59
Roger Rainey8-Dec-09 4:59 
AnswerRe: Application.DoEvents() equivalent in aspx Pin
Dave Kreskowiak8-Dec-09 5:26
mveDave Kreskowiak8-Dec-09 5:26 
AnswerGetting status of batch process Pin
David Mujica8-Dec-09 6:14
David Mujica8-Dec-09 6:14 
QuestionHow to format Datagridview Columns Decimal Values? Pin
Paramu19738-Dec-09 4:04
Paramu19738-Dec-09 4:04 
AnswerRe: How to format Datagridview Columns Decimal Values? Pin
Dave Kreskowiak9-Dec-09 4:22
mveDave Kreskowiak9-Dec-09 4:22 
GeneralRe: How to format Datagridview Columns Decimal Values? Pin
Paramu19739-Dec-09 21:52
Paramu19739-Dec-09 21:52 
Questionhow to send mail by visual basic ? Pin
Golden Jing8-Dec-09 1:02
Golden Jing8-Dec-09 1:02 
AnswerRe: how to send mail by visual basic ? Pin
Paramu19738-Dec-09 4:35
Paramu19738-Dec-09 4:35 
GeneralRe: how to send mail by visual basic ? [modified] Pin
Golden Jing8-Dec-09 15:21
Golden Jing8-Dec-09 15:21 
QuestionSave Csv or excel file to sql using vb6.0 Pin
Parag Raibagkar7-Dec-09 18:49
Parag Raibagkar7-Dec-09 18:49 
AnswerRe: Save Csv or excel file to sql using vb6.0 Pin
Eddy Vluggen8-Dec-09 0:26
professionalEddy Vluggen8-Dec-09 0:26 
GeneralRe: Save Csv or excel file to sql using vb6.0 Pin
Parag Raibagkar8-Dec-09 20:04
Parag Raibagkar8-Dec-09 20:04 
GeneralRe: Save Csv or excel file to sql using vb6.0 Pin
Dave Kreskowiak9-Dec-09 3:52
mveDave Kreskowiak9-Dec-09 3:52 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.