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

Visual Basic

 
GeneralRe: Detect if a messagebox is shown Pin
Eddy Vluggen22-May-14 22:31
professionalEddy Vluggen22-May-14 22:31 
GeneralRe: Detect if a messagebox is shown Pin
Dave Kreskowiak22-May-14 11:11
mveDave Kreskowiak22-May-14 11:11 
GeneralRe: Detect if a messagebox is shown Pin
Dave Kreskowiak22-May-14 11:11
mveDave Kreskowiak22-May-14 11:11 
GeneralRe: Detect if a messagebox is shown Pin
dilkonika22-May-14 13:50
dilkonika22-May-14 13:50 
QuestionLoad method with file URL file location reference Pin
Member 1066669819-May-14 22:33
Member 1066669819-May-14 22:33 
AnswerRe: Load method with file URL file location reference Pin
Eddy Vluggen20-May-14 5:23
professionalEddy Vluggen20-May-14 5:23 
GeneralRe: Load method with file URL file location reference Pin
Member 1066669820-May-14 5:44
Member 1066669820-May-14 5:44 
QuestionListing Directory using FTPwebrequest and updating DB tables Pin
Sachin k Rajput 19-May-14 3:33
Sachin k Rajput 19-May-14 3:33 
I'm listing the directories using FTPWebRequest and updating the data into a sql table. My code is:


VB
If Con.State = ConnectionState.Closed Then Con.Open()
            ObjEventlog.WriteEventLog("TimerListing_Task()", "Connection Is Open Now")
            Dim Rs As SqlDataReader = com.ExecuteReader(CommandBehavior.CloseConnection)
            While Rs.Read
                ''ExecuteQuerys("Delete from temp_Listing_result where deviceID=" & Rs(0))
                ListBox1.Items.Add("Listing DeviceID-->" & Rs(0).ToString & " Start...")
                ObjEventlog.WriteEventLog("TimerListing_Task()", "Table temp_Listing_result Is Refresh Now For Device ID---> " & Rs(0).ToString)
                Dim arr() As String
                Dim request As FtpWebRequest = WebRequest.Create("ftp://" & Rs(1) & ":" & Rs(2) & "/" & Rs(3))
                request.Credentials = New NetworkCredential(Rs(4).ToString, Rs(5).ToString)
                request.Method = WebRequestMethods.Ftp.ListDirectoryDetails
                Dim response As FtpWebResponse = request.GetResponse()
                Dim responseStream As Stream = response.GetResponseStream()
                Dim reader As StreamReader = New StreamReader(responseStream)
                ObjEventlog.WriteEventLog("TimerListing_Task()", "WebRequest is Created with ----> " & "ftp://" & Rs(1) & ":" & Rs(2) & "/" & Rs(3))
                Dim loadData As String = ""
                Dim lineNumber As Integer = 0
                While loadData IsNot Nothing
                    loadData = reader.ReadLine()

                    arr = Split(loadData, vbNewLine)
                    For i = 0 To UBound(arr)
                        If Len(arr(i)) > 0 Then
                            Dim ss As String = arr(i)
                            ObjEventlog.WriteEventLog("TimerListing_Task()", "WebRequest Listing Result---> " & ss)
                            Dim isFolder As String = ss.Substring(0, 4)
                            If isFolder <> "drwx" Then
                                ss = Trim(ss.Substring(28))
                                ObjEventlog.WriteEventLog("TimerListing_Task()", "WebRequest Listing Result After Split---> " & ss)
                                Dim s() As String = vb.Split(ss, " ")
                                Dim modifyDate As String = s(1).ToString & " " & s(2).ToString & " " & s(3).ToString
                                Dim Clip() As String = vb.Split(s(4).ToString, ".")
                                If Clip.Length = 2 Then

                                    ExecuteQuerys("insert into temp_Listing_result (deviceID, ClipName, ClipSize, ModifyDate, Extn) values(" & Rs(0) & ",'" & Clip(0).ToString & "','" & s(0).ToString & "','" & modifyDate & "','" & Clip(1).ToString & "')")

                                    SqlQry = "update temp_Listing_result_process deviceID=" & Rs(0) & ", ClipName='" & Clip(0).ToString & "', ClipSize='" & s(0).ToString & "', ModifyDate='" & modifyDate & "', Extn='" & Clip(1).ToString & "' where deviceID=" & Rs(0) & ""
                                    ExecuteQuerys(SqlQry)

                                Else



                                    ExecuteQuerys("insert into temp_Listing_result (deviceID, ClipName, ClipSize, ModifyDate, Extn) values(" & Rs(0) & ",'" & Clip(0).ToString & "','" & s(0).ToString & "','" & modifyDate & "','')")



                                    SqlQry = "update temp_Listing_result_process deviceID=" & Rs(0) & ", ClipName='" & Clip(0).ToString & "', ClipSize='" & s(0).ToString & "', ModifyDate='" & modifyDate & "' where deviceID=" & Rs(0) & ""
                                    ExecuteQuerys(SqlQry)


                                    'ExecuteQuerys("insert into temp_Listing_result (deviceID, ClipName, ClipSize, ModifyDate, Extn) values(" & Rs(0) & ",'" & Clip(0).ToString & "','" & s(0).ToString & "','" & modifyDate & "','')")
                                End If
                                ListBox1.Items.Add(arr(i))
                            Else
                                ObjEventlog.WriteEventLog("TimerListing_Task()", "Folder Found ,Listing Not Done For Folder")
                            End If
                        End If



Quote:
Here I've done Listing and throwing the data in the table temp_Listing_result.

If I'm inserting data only in single table then It's working fine but I want to update another temp_Listing_result_process table with previous table.

I'm getting wrong data: The data is only of one device and table is consisting only one directory data repetitively.

I'm having 4 directories, But when I listing it's listing only one device and inserting the same data again and again.

Please share your experiences.

Thanks!

QuestionVBScript: Conversion XML to Excel Pin
Member 1066669818-May-14 21:39
Member 1066669818-May-14 21:39 
AnswerRe: VBScript: Conversion XML to Excel Pin
Chris Quinn18-May-14 22:52
Chris Quinn18-May-14 22:52 
GeneralRe: VBScript: Conversion XML to Excel Pin
Member 1066669818-May-14 23:05
Member 1066669818-May-14 23:05 
GeneralRe: VBScript: Conversion XML to Excel Pin
Chris Quinn18-May-14 23:32
Chris Quinn18-May-14 23:32 
GeneralRe: VBScript: Conversion XML to Excel Pin
Member 1066669819-May-14 1:10
Member 1066669819-May-14 1:10 
GeneralRe: VBScript: Conversion XML to Excel Pin
Member 1066669819-May-14 2:37
Member 1066669819-May-14 2:37 
GeneralRe: VBScript: Conversion XML to Excel Pin
Eddy Vluggen19-May-14 2:59
professionalEddy Vluggen19-May-14 2:59 
GeneralRe: VBScript: Conversion XML to Excel Pin
Member 1066669819-May-14 3:10
Member 1066669819-May-14 3:10 
GeneralRe: VBScript: Conversion XML to Excel Pin
Chris Quinn19-May-14 3:15
Chris Quinn19-May-14 3:15 
GeneralRe: VBScript: Conversion XML to Excel Pin
Eddy Vluggen19-May-14 7:39
professionalEddy Vluggen19-May-14 7:39 
QuestionVB.Net 2008 Pin
Virendra Singh Bhanu16-May-14 0:29
Virendra Singh Bhanu16-May-14 0:29 
AnswerRe: VB.Net 2008 Pin
Richard MacCutchan16-May-14 0:50
mveRichard MacCutchan16-May-14 0:50 
GeneralRe: VB.Net 2008 Pin
Virendra Singh Bhanu16-May-14 0:56
Virendra Singh Bhanu16-May-14 0:56 
GeneralRe: VB.Net 2008 Pin
Richard MacCutchan16-May-14 1:14
mveRichard MacCutchan16-May-14 1:14 
QuestionRe: VB.Net 2008 Pin
Eddy Vluggen16-May-14 3:02
professionalEddy Vluggen16-May-14 3:02 
QuestionList(Of ObjectWithProperties) distinct property values Pin
Johan Hakkesteegt15-May-14 3:32
Johan Hakkesteegt15-May-14 3:32 
AnswerRe: List(Of ObjectWithProperties) distinct property values Pin
Richard MacCutchan15-May-14 3:49
mveRichard MacCutchan15-May-14 3:49 

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.