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

Visual Basic

 
QuestionActive X Pin
p_196018-Mar-09 23:03
p_196018-Mar-09 23:03 
AnswerRe: Active X Pin
Steven J Jowett18-Mar-09 23:52
Steven J Jowett18-Mar-09 23:52 
Questionpassing a word from word document to textbox Pin
hyperalergelo18-Mar-09 22:59
hyperalergelo18-Mar-09 22:59 
AnswerRe: passing a word from word document to textbox Pin
Christian Graus18-Mar-09 23:49
protectorChristian Graus18-Mar-09 23:49 
GeneralRe: passing a word from word document to textbox Pin
hyperalergelo19-Mar-09 0:30
hyperalergelo19-Mar-09 0:30 
GeneralRe: passing a word from word document to textbox Pin
hyperalergelo19-Mar-09 15:50
hyperalergelo19-Mar-09 15:50 
GeneralRe: passing a word from word document to textbox Pin
hyperalergelo20-Mar-09 0:35
hyperalergelo20-Mar-09 0:35 
Questionindex out of range exception Pin
zaimah18-Mar-09 21:10
zaimah18-Mar-09 21:10 
im running this function to convert a list of code into a certain standard.. the problem is, when i choose the files (where i get the value of coop) and directory (where i compare coop with the list in the directory) this msg come out "index out of range exception". But if i choose local file and directory example file from my desktop and my d:/ there's np error.. but if i choose the file from other map drive the error happen at the Catch part.

Private Sub SEMAK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SEMAK.Click

        Dim fileName As String = TextBox1.Text.Trim
        Dim lineNumber As Integer = 0
        Dim sr As StreamReader = New StreamReader(fileName)
        Dim conn As New SqlClient.SqlConnection("Data Source=10.0.0.70;User ID= sysadm;Password=sysadm;Initial Catalog=SPGA_Latihan;Persist Security Info=True;")

        Dim tarikh As String = ""
        Dim runNo As String = ""
        Dim coop As String = ""
        Dim line As String = ""


        Do
            line = sr.ReadLine()

            If line <> Nothing Then
                Try
                    tarikh = line.Substring(0, 8).Trim()
                    runNo = line.Substring(9, 5).Trim()
                    coop = line.Substring(15).Trim()

                Catch ex As Exception
                    Console.Write(ex.ToString())
                End Try

                Dim strSQL As String = "INSERT INTO portal (tarikh,runNo, coop) VALUES (@tarikh, @runNo, @coop)"
                Dim cmd As New System.Data.SqlClient.SqlCommand(strSQL, conn)

                conn.Open()

                cmd.Parameters.Add(New SqlClient.SqlParameter("@tarikh", SqlDbType.Char, 8))
                cmd.Parameters("@tarikh").Value = tarikh

                cmd.Parameters.Add(New SqlClient.SqlParameter("@runNo", SqlDbType.Char, 20))
                cmd.Parameters("@runNo").Value = runNo

                cmd.Parameters.Add(New SqlClient.SqlParameter("@coop", SqlDbType.VarChar, 100))
                cmd.Parameters("@coop").Value = coop

                cmd.ExecuteNonQuery()
                conn.Close()
                
                Dim dirB1 As DirectoryInfo = New DirectoryInfo(TextBox2.Text)





                Try

                    convertCoop(coop)



                    Dim dA1 As DirectoryInfo
                    Dim dirB2 As FileSystemInfo() = dirB1.GetDirectories

                    Dim strSQL2 As String = "SELECT folder, portal FROM  kodPortal"
                    Dim cmd2 As New System.Data.SqlClient.SqlCommand(strSQL2, conn)

                    For Each dA1 In dirB2
                        If dA1.Name = portal Then

                            Dim dA2 As DirectoryInfo
                            Dim dirB3 As FileSystemInfo() = dA1.GetDirectories

                            For Each dA2 In dirB3
                                If dA2.Name = "Fail_Bayaran" Then



                                    Dim dA3 As DirectoryInfo
                                    Dim dirB4 As FileSystemInfo() = dA2.GetDirectories

                                    For Each dA3 In dirB4
                                        If dA3.Name = coop Then

                                            Dim dA4 As FileSystemInfo
                                            Dim dirB5 As FileSystemInfo() = dA3.GetFileSystemInfos

                                            For Each dA4 In dirB5
                                                If dA4.Name <> runNo Then
                                                    MsgBox(coop)

                                                End If
                                            Next dA4
                                        End If
                                    Next dA3
                                End If
                            Next (dA2)
                        End If
                    Next dA1



                Catch ex As Exception

                End Try


            End If

        Loop Until line Is Nothing

        sr.Close()


    End Sub



Private Sub convertCoop(ByVal coop As String)

        Dim conn1 As New SqlClient.SqlConnection("Data Source=10.0.0.70;User ID= sysadm;Password=sysadm;Initial Catalog=SPGA_Latihan;Persist Security Info=True;")
        Dim comm As SqlClient.SqlDataAdapter = Nothing
        Dim ds As DataSet = New DataSet()

        Try
            Dim strSQL2 As String = "SELECT folder, portal FROM kodPortal WHERE folder ='" & coop & "'"

            conn1.Open()
            comm = New SqlClient.SqlDataAdapter(strSQL2, conn1)
            comm.Fill(ds, "kodPortal")

            portal = ds.Tables(0).Rows(0).Item("portal")


            conn1.Close()

        Catch ex As Exception 
            MsgBox(ex.Message)

        Finally
            If Not conn1 Is Nothing And conn1.State = ConnectionState.Open Then
                conn1.Close()
            End If
            conn1 = Nothing
            comm = Nothing
        End Try

    End Sub


AnswerRe: index out of range exception Pin
Christian Graus18-Mar-09 21:36
protectorChristian Graus18-Mar-09 21:36 
QuestionRe: index out of range exception Pin
zaimah19-Mar-09 0:40
zaimah19-Mar-09 0:40 
AnswerRe: index out of range exception Pin
Steven J Jowett18-Mar-09 23:58
Steven J Jowett18-Mar-09 23:58 
GeneralRe: index out of range exception Pin
zaimah19-Mar-09 0:43
zaimah19-Mar-09 0:43 
Questionkill process [modified] Pin
hrishiS18-Mar-09 20:27
hrishiS18-Mar-09 20:27 
AnswerRe: kill process Pin
_Damian S_18-Mar-09 20:32
professional_Damian S_18-Mar-09 20:32 
GeneralRe: kill process Pin
hrishiS18-Mar-09 20:46
hrishiS18-Mar-09 20:46 
GeneralRe: kill process Pin
Christian Graus18-Mar-09 20:57
protectorChristian Graus18-Mar-09 20:57 
GeneralRe: kill process Pin
hrishiS18-Mar-09 23:48
hrishiS18-Mar-09 23:48 
GeneralRe: kill process Pin
Christian Graus18-Mar-09 23:53
protectorChristian Graus18-Mar-09 23:53 
GeneralRe: kill process Pin
hrishiS19-Mar-09 0:05
hrishiS19-Mar-09 0:05 
GeneralRe: kill process Pin
Christian Graus19-Mar-09 0:19
protectorChristian Graus19-Mar-09 0:19 
GeneralRe: kill process Pin
hrishiS19-Mar-09 0:48
hrishiS19-Mar-09 0:48 
GeneralRe: kill process Pin
Yusuf19-Mar-09 4:22
Yusuf19-Mar-09 4:22 
GeneralRe: kill process Pin
Yusuf19-Mar-09 0:21
Yusuf19-Mar-09 0:21 
GeneralRe: kill process Pin
hrishiS19-Mar-09 0:50
hrishiS19-Mar-09 0:50 
GeneralRe: kill process Pin
Eytukan19-Mar-09 0:21
Eytukan19-Mar-09 0:21 

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.