Click here to Skip to main content
15,887,776 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: Wrapper for VB6 error - "The system cannot find the file specified." Pin
Marcus J. Smith31-Oct-07 8:14
professionalMarcus J. Smith31-Oct-07 8:14 
Questioncrystal reports labels Pin
Tom Deketelaere30-Oct-07 6:16
professionalTom Deketelaere30-Oct-07 6:16 
QuestionHELP Create web service step by step tutorial Pin
kendo1730-Oct-07 5:55
kendo1730-Oct-07 5:55 
AnswerRe: HELP Create web service step by step tutorial Pin
Dave Kreskowiak31-Oct-07 5:25
mveDave Kreskowiak31-Oct-07 5:25 
GeneralRe: HELP Create web service step by step tutorial Pin
kendo1731-Oct-07 10:19
kendo1731-Oct-07 10:19 
QuestionOpening A Text File InTo A DataGrid Pin
FreakNikon30-Oct-07 5:04
FreakNikon30-Oct-07 5:04 
AnswerRe: Opening A Text File InTo A DataGrid Pin
Dave Kreskowiak30-Oct-07 5:48
mveDave Kreskowiak30-Oct-07 5:48 
AnswerRe: Opening A Text File InTo A DataGrid Pin
C1AllenS30-Oct-07 5:51
C1AllenS30-Oct-07 5:51 
Hello Chris,

I believe this code snippet should help you atleast to browse and load text files into the
datagrid.

Dim strFileName As String
Dim strFilePath As String
Dim sSlash As Single
Dim FileDialog As New OpenFileDialog

Try
With FileDialog
.Title = "Import Sage CSV file"
.InitialDirectory = "D:\Accounts"
.Filter = "Text Files | *.txt|All files|*.*"

.ShowDialog()

sSlash = InStrRev(.FileName, "\")
strFilePath = Mid(.FileName, 1, sSlash)
strFileName = Mid(.FileName, sSlash + 1, Len(.FileName))
End With


Dim strConnectionString As String = "Provider=Microsoft.Jet.OLEDB.4.0;" _
& "Data Source=" & strFilePath & ";" _
& "Extended Properties=""text;HDR=NO;FMT=Delimited"""

Dim conn As New OleDb.OleDbConnection(strConnectionString)
conn.Open() ' Open connection with the database.

Dim objCmdSelect As New OleDb.OleDbCommand("SELECT * FROM [" & strFileName & "]", conn) ' Create new OleDbCommand to return data from worksheet.
'Dim objCmdSelect As New OleDb.OleDbCommand("Select * from [Sheet1$]", conn) ' Create new OleDbCommand to return data from worksheet.

' Create new OleDbDataAdapter that is used to build a DataSet based on the preceding SQL SELECT statement.
Dim objAdapter1 As New OleDb.OleDbDataAdapter
objAdapter1.SelectCommand = objCmdSelect 'Pass the Select command to the adapter.
Dim objDataset1 As New DataSet 'Create new DataSet to hold information from the worksheet.
objAdapter1.Fill(objDataset1, "TextData") 'Fill the DataSet with the information from the file.


Me.DataGridView1.DataSource = objDataset1.Tables(0).DefaultView 'Build a table from the original data.

conn.Close() 'Clean up objects.

Catch ex As Exception
MsgBox(ex.Message).ToString()

End Try

I hope this helps.


Allen Smith

Software Engineer
ComponentOne LLC
www.componentone.com
Questionhow to use double buffer in vb 2005? Pin
jiuhu30-Oct-07 4:40
jiuhu30-Oct-07 4:40 
AnswerRe: how to use double buffer in vb 2005? Pin
Dave Kreskowiak30-Oct-07 5:18
mveDave Kreskowiak30-Oct-07 5:18 
GeneralRe: how to use double buffer in vb 2005? Pin
jiuhu30-Oct-07 5:31
jiuhu30-Oct-07 5:31 
GeneralRe: how to use double buffer in vb 2005? Pin
Dave Kreskowiak30-Oct-07 5:45
mveDave Kreskowiak30-Oct-07 5:45 
GeneralRe: how to use double buffer in vb 2005? Pin
jiuhu30-Oct-07 11:59
jiuhu30-Oct-07 11:59 
QuestionThreading ? [modified] Pin
tim63730-Oct-07 2:58
tim63730-Oct-07 2:58 
AnswerRe: Threading ? Pin
Abhijit Jana30-Oct-07 3:20
professionalAbhijit Jana30-Oct-07 3:20 
GeneralRe: Threading ? Pin
tim63730-Oct-07 3:55
tim63730-Oct-07 3:55 
GeneralRe: Threading ? Pin
Abhijit Jana30-Oct-07 4:13
professionalAbhijit Jana30-Oct-07 4:13 
AnswerRe: Threading ? Pin
svanwass31-Oct-07 5:35
svanwass31-Oct-07 5:35 
QuestionGetting database names with windows authentication Pin
dptalt30-Oct-07 2:58
dptalt30-Oct-07 2:58 
AnswerRe: Getting database names with windows authentication Pin
Abhijit Jana30-Oct-07 3:31
professionalAbhijit Jana30-Oct-07 3:31 
GeneralRe: Getting database names with windows authentication Pin
dptalt5-Nov-07 4:38
dptalt5-Nov-07 4:38 
Questionshowing a modal form at a location Pin
aransiola30-Oct-07 2:39
aransiola30-Oct-07 2:39 
AnswerRe: showing a modal form at a location Pin
Tom Deketelaere30-Oct-07 2:48
professionalTom Deketelaere30-Oct-07 2:48 
AnswerRe: showing a modal form at a location Pin
nlarson1130-Oct-07 5:08
nlarson1130-Oct-07 5:08 
QuestionDateTimePicker Pin
nishkarsh_k29-Oct-07 22:56
nishkarsh_k29-Oct-07 22:56 

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.