Public Function ReadExcelIntoDataset(ByVal file As String) As Data.DataSet
'Create the DataSet that will hold the data from the sheet
Dim dsExcel As New Data.DataSet
'First name sure the file exists
If Not IO.File.Exists(file) Then
MessageBox.Show("The file provided doesn't exist. Please check the name and try again")
Else
Try
'Declare the variables needed for the reading of the Excel file
Dim sOleDbString As New String("SELECT * FROM [sheet1$]")
'Create our connection to the Excel sheet
Dim cnExcel As New Data.OleDb.OleDbConnection("provider=Microsoft.Jet.OLEDB.4.0; data source='" & _
file & " '; " & "Extended Properties=Excel 11.0;")
'Create our command object
Dim cmdExcel As New Data.OleDb.OleDbDataAdapter(sOleDbString, cnExcel)
'Now we try to fill the DataSet with the data from the Excel file
Try
'Fill was successful
cmdExcel.Fill(dsExcel)
'Catch any errors that have occurred
Catch ex As Exception 'Fill failed
MessageBox.Show(ex.Message)
dsExcel = Nothing
'Finally close the connection
Finally
cnExcel.Close()
End Try
'Catch any errors that may have occurred
Catch ex As Exception
MessageBox.Show(ex.Message)
dsExcel = Nothing
End Try
Return dsExcel
End If
End Function
-
game design team
We have emerged as the leading online community for game development of all levels. Our expertise encases all facets for writing PC , Mobile and Online of 2D and 3D Gaming programming and applications development, for instance by using the latest 3D engines, scripting languages and animation techniques, our experienced and qualified team deals with all kind of requirements, whether it be a beginner's choice or an expert gaming action. Most importantly, we endeavor to offer compelling solution and eminent support to our growing community of prospective players and customers.
Private Declare Function SystemParametersInfo Lib "user32" Alias "SystemParametersInfoA" _
(ByVal uAction As Integer, ByVal uParam As Integer, ByVal lpvParam As String, ByVal fuWinIni As Integer) _
As Integer
'''
''' Changes the desktop background image
'''
'''
Path to the image
''' Makes changes to keep the image after a reboot
'''
Public Sub ChangeBackground(ByVal FileName As String, ByVal KeepAfterBoot As Boolean)
Try
If KeepAfterBoot = True Then
SystemParametersInfo(20, 0, FileName, 1)
Else
SystemParametersInfo(20, 0, FileName, 0)
End If
Catch ex As Exception
MsgBox(ex)
End Try
End Sub
Subscribe to:
Posts (Atom)