Click here to Skip to main content
15,902,635 members
Home / Discussions / Visual Basic
   

Visual Basic

 
AnswerRe: Getting error System.InvalidCastException occurred Pin
Richard MacCutchan11-May-12 2:45
mveRichard MacCutchan11-May-12 2:45 
GeneralRe: Getting error System.InvalidCastException occurred Pin
KireronThunderStone11-May-12 9:24
KireronThunderStone11-May-12 9:24 
GeneralRe: Getting error System.InvalidCastException occurred Pin
Richard MacCutchan11-May-12 22:45
mveRichard MacCutchan11-May-12 22:45 
GeneralRe: Getting error System.InvalidCastException occurred Pin
Luc Pattyn12-May-12 1:55
sitebuilderLuc Pattyn12-May-12 1:55 
AnswerRe: Getting error System.InvalidCastException occurred Pin
Bernhard Hiller11-May-12 3:05
Bernhard Hiller11-May-12 3:05 
GeneralRe: Getting error System.InvalidCastException occurred Pin
KireronThunderStone11-May-12 9:23
KireronThunderStone11-May-12 9:23 
GeneralRe: Getting error System.InvalidCastException occurred Pin
Bernhard Hiller13-May-12 20:22
Bernhard Hiller13-May-12 20:22 
QuestionHow can i Import Mutiple DBF files to different Tables in MDB Pin
baru_240910-May-12 20:46
baru_240910-May-12 20:46 
Here is the code i am using for this

Imports System
Imports System.IO
Imports System.Data.OleDb
Imports ADOX
Imports System.Data
Imports OLEDBError
Public Class Main
Private filename As String
Private TexttxtFileContents As String
Private paths() As String = Split(Environment.GetEnvironmentVariable("PATH"), ";")



Private Sub SplitContainer1_Panel1_Paint(ByVal sender As System.Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles SplitContainer1.Panel1.Paint

End Sub

Private Sub HTRADIO_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles HTRADIO.CheckedChanged
HTGROUP.Visible = True
HTLTGB.Visible = False
End Sub

Private Sub HTANDLT_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles HTANDLT.CheckedChanged
HTLTGB.Visible = True


End Sub


Private Sub HTCONButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles HTCONButton.Click

Dim start_dir As String = System.Windows.Forms.Application.StartupPath
Try
With odlgTextFile
' See btnRetriveFileNames_Click for explanations of default values
' for the properties.

' Check to ensure that the selected file exists. Dialog box displays
' a warning otherwise.
.CheckFileExists = True

' Check to ensure that the selected path exists. Dialog box displays
' a warning otherwise.
'.CheckPathExists = True

' Get or set default extension. Doesn't include the leading ".".
.DefaultExt = "dbf"

' Return the file referenced by a link? If False, simply returns the selected link
' file. If True, returns the file linked to the LNK file.
'.DereferenceLinks = True

' Just as in VB6, use a set of pairs of filters, separated with "|". Each
' pair consists of a description|file spec. Use a "|" between pairs. No need to put a
' trailing "|". You can set the FilterIndex property as well, to select the default
' filter. The first filter is numbered 1 (not 0). The default is 1.

.Filter = _
"Database files (*.dbf)|*.dbf|All files|*.*"

.Multiselect = False

' Restore the original directory when done selecting
' a file? If False, the current directory changes
' to the directory in which you selected the file.
' Set this to True to put the current folder back
' where it was when you started.
' The default is False.
.RestoreDirectory = True


' Show the Help button and Read-Only checkbox?
.ShowHelp = True
.ShowReadOnly = False

' Start out with the read-only check box checked?
' This only make sense if ShowReadOnly is True.
.ReadOnlyChecked = False

.Title = "Select a file to open"

' Only accept valid Win32 file names?
.ValidateNames = True

If .ShowDialog = Windows.Forms.DialogResult.OK Then

Try


HTCONDTextBox.Text = .FileName

'Data Copy to GEC-Neplan Folder

Dim FileToCopy As String
Dim NewCopy As String

FileToCopy = .FileName
NewCopy = "C:\GEC-NEPLAN\HT-CONDCUTOR.DBF"

If System.IO.File.Exists(FileToCopy) = True Then
System.IO.File.Copy(FileToCopy, NewCopy)

End If

'HTCONDTextBox.Text = My.Computer.FileSystem.ReadAllText(.FileName)

Catch fileException As Exception
Throw fileException
End Try
End If

End With
Catch ex As Exception

'MsgBox(ex.Message, MsgBoxStyle.Exclamation, Me.Text)


End Try



End Sub




Private Sub HTPOLEButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles HTPOLEButton.Click


Try
With odlgTextFile
' See btnRetriveFileNames_Click for explanations of default values
' for the properties.

' Check to ensure that the selected file exists. Dialog box displays
' a warning otherwise.
.CheckFileExists = True

' Check to ensure that the selected path exists. Dialog box displays
' a warning otherwise.
.CheckPathExists = True

' Get or set default extension. Doesn't include the leading ".".
.DefaultExt = "dbf"

' Return the file referenced by a link? If False, simply returns the selected link
' file. If True, returns the file linked to the LNK file.
.DereferenceLinks = True

' Just as in VB6, use a set of pairs of filters, separated with "|". Each
' pair consists of a description|file spec. Use a "|" between pairs. No need to put a
' trailing "|". You can set the FilterIndex property as well, to select the default
' filter. The first filter is numbered 1 (not 0). The default is 1.
.Filter = _
"Database files (*.dbf)|*.dbf|All files|*.*"

.Multiselect = False

' Restore the original directory when done selecting
' a file? If False, the current directory changes
' to the directory in which you selected the file.
' Set this to True to put the current folder back
' where it was when you started.
' The default is False.
.RestoreDirectory = True


' Show the Help button and Read-Only checkbox?
.ShowHelp = True
.ShowReadOnly = False

' Start out with the read-only check box checked?
' This only make sense if ShowReadOnly is True.
.ReadOnlyChecked = False

.Title = "Select a file to open"

' Only accept valid Win32 file names?
.ValidateNames = True


If .ShowDialog = Windows.Forms.DialogResult.OK Then

Try


HTPOLETextBox.Text = .FileName



'Data Copy to GEC-Neplan Folder

Dim FileToCopy As String
Dim NewCopy As String

FileToCopy = .FileName
NewCopy = "C:\GEC-NEPLAN\HT-POLES.DBF"

If System.IO.File.Exists(FileToCopy) = True Then
System.IO.File.Copy(FileToCopy, NewCopy)

End If

Catch fileException As Exception
Throw fileException
End Try
End If


End With
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Exclamation, Me.Text)

End Try



End Sub

Private Sub NEXT1Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NEXTHCButton.Click
Call Link_Table("HTCON", "HT-CONDCUTOR")


End Sub







Private Sub Main_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

'Check Wheter Folder Exists or Not;If Exists Delete and Creat New One
If (System.IO.Directory.Exists("C:\GEC-NEPLAN")) Then
System.IO.Directory.Delete("C:\GEC-NEPLAN", True)
End If
System.IO.Directory.CreateDirectory("C:\GEC-NEPLAN")

Dim cat As New Catalog()

Try

cat.Create("Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=C:\GEC-NEPLAN\SHAPE-NEPLAN.mdb")

'MessageBox.Show("Database Created.", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information)

Catch Excep As System.Runtime.InteropServices.COMException
MessageBox.Show(Excep.Message, "Error Database Not Created", MessageBoxButtons.OK, MessageBoxIcon.Error)

Finally
cat = Nothing
End Try


End Sub



Public Sub Link_Table(ByVal filename As String, ByVal name As String)
'*****************************************************
'Creates a link in our database to the dbf 'filename'
'*****************************************************
'References:
'ADODB ( .Net:ADODB )
'ADOX ( COM:Microsoft ADO Ext 2.8 for DDL and Security )
Dim cat As New ADOX.Catalog
Dim tbl As New ADOX.Table
Dim con As New ADODB.Connection

'Copy long named files to allow an access connection
If Len(System.IO.Path.GetFileNameWithoutExtension(filename)) > 8 Then
System.IO.File.Copy(filename, System.IO.Path.GetDirectoryName(filename) & "\" & name & ".dbf", True)
filename = System.IO.Path.GetDirectoryName(filename) & "\" & name & ".dbf"
End If

'A connection to the database where you are adding the link
con.ConnectionString = "Data Source=""C:\GEC-NEPLAN\SHAPE-NEPLAN.mdb"";Jet OLEDB:Engine Type=5;Provider=""Microsoft.Jet.OLEDB.4.0"";Mode=Share Deny None;Jet OLEDB:Encrypt Database=False;User ID=Admin;Jet OLEDB:Global Bulk Transactions=1"
con.Open()
cat.ActiveConnection = con

'Get Rid of the old table if it exists
On Error Resume Next ' If the table is not there, ignore the resulting error
cat.Tables.Delete(name)
On Error GoTo 0

' Create the new table.
With tbl
.Name = name
.ParentCatalog = cat
' Set the properties to create the link.
.Properties("Jet OLEDB:Create Link").Value = True
.Properties("Jet OLEDB:Link Datasource").Value = System.IO.Path.GetDirectoryName(filename)
.Properties("Jet OLEDB:Link Provider String").Value = "Dbase IV"
.Properties("Jet OLEDB:Remote Table Name").Value = name
End With

' Append the table to the tables collection of the catalog.
cat.Tables.Append(tbl)
con.Close()
' Clean up.
cat = Nothing

End Sub




End Class
AnswerRe: How can i Import Mutiple DBF files to different Tables in MDB Pin
Eddy Vluggen11-May-12 0:34
professionalEddy Vluggen11-May-12 0:34 
GeneralRe: How can i Import Mutiple DBF files to different Tables in MDB Pin
baru_240911-May-12 1:50
baru_240911-May-12 1:50 
GeneralRe: How can i Import Mutiple DBF files to different Tables in MDB Pin
Eddy Vluggen11-May-12 5:44
professionalEddy Vluggen11-May-12 5:44 
QuestionStarting program with a command line parameter Pin
KreativeKai10-May-12 4:53
professionalKreativeKai10-May-12 4:53 
AnswerRe: Starting program with a command line parameter Pin
Dave Kreskowiak10-May-12 9:20
mveDave Kreskowiak10-May-12 9:20 
GeneralRe: Starting program with a command line parameter Pin
KreativeKai10-May-12 9:29
professionalKreativeKai10-May-12 9:29 
GeneralRe: Starting program with a command line parameter Pin
Dave Kreskowiak10-May-12 12:53
mveDave Kreskowiak10-May-12 12:53 
GeneralRe: Starting program with a command line parameter Pin
KreativeKai11-May-12 1:29
professionalKreativeKai11-May-12 1:29 
GeneralRe: Starting program with a command line parameter Pin
Dave Kreskowiak11-May-12 1:38
mveDave Kreskowiak11-May-12 1:38 
GeneralRe: Starting program with a command line parameter Pin
KreativeKai11-May-12 1:57
professionalKreativeKai11-May-12 1:57 
AnswerRe: Starting program with a command line parameter Pin
Sasha Laurel15-May-12 13:40
Sasha Laurel15-May-12 13:40 
AnswerRe: Starting program with a command line parameter Pin
pcusr806-Jun-12 3:57
pcusr806-Jun-12 3:57 
QuestionDRAG & DROP LABELS SWAP Pin
User 871522210-May-12 0:57
professionalUser 871522210-May-12 0:57 
AnswerRe: DRAG & DROP LABELS SWAP Pin
Dave Kreskowiak10-May-12 2:21
mveDave Kreskowiak10-May-12 2:21 
AnswerRe: DRAG & DROP LABELS SWAP Pin
User 871522210-May-12 23:11
professionalUser 871522210-May-12 23:11 
QuestionGet currency conversion from website Pin
wouterv819-May-12 13:33
wouterv819-May-12 13:33 
AnswerRe: Get currency conversion from website Pin
Dave Kreskowiak9-May-12 18:44
mveDave Kreskowiak9-May-12 18:44 

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.