Jeremy Tourville
Member
- Joined
- May 22, 2015
- Messages
- 5
- Programming Experience
- Beginner
My code appears to be working as expected except for getting the column/field named "Foundstone" to update in the source database. I am trying to figure out what I am doing wrong. I am not seeing any errors or exceptions being thrown. I have used this tutorial as a basis for my learning database coding - Visual Basic .NET programming for Beginners - Navigate a Database I have done a lot of reading about the different methods available to work with databases. I have really tried to educate myself before posting here. (I am brand new to both programming in general and database programming. I only had one class as part of my computer major (networking not programming) If I ask a question that seems like basic knowledge it may be because it's all new to me. I am very glad to read and try to educate myself as much as possible so please share links.)
My code is below
I tried to do some debugging. I am seeing something like a pin in the "ds.Tables("MAIN").Rows(i).Item("Foundstone") = "NotFound" " section if I hover my mouse on the word tables. I can see what I think might be an error??? In order to evaluate an indexed property, the property must be qualified and the arguments must be explicitly supplied by the user. Thoughts? and maybe this has nothing to do with the real issue...
My code is below
Imports System Imports System.Data Imports System.Data.OleDb Imports System.Windows.Forms.HtmlDocument Public Class Form1 Dim con As New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=|DataDirectory|\VulnScanData.accdb;Persist Security Info=True;Jet OLEDB:Database Password=********") Dim ds As New DataSet Dim da As OleDb.OleDbDataAdapter Dim sql As String Dim maxrows As Integer Dim result As Integer Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load WebBrowser1.Navigate("https://fs-enterprise.my.private.url/") con.Open() 'opens connection to database End Sub Private Sub Button1_Click(sender As Object, e As EventArgs) Handles BtnLogin.Click WebBrowser1.Document.GetElementById("name").SetAttribute("value", TextBox1.Text) WebBrowser1.Document.GetElementById("password").SetAttribute("value", TextBox2.Text) WebBrowser1.Document.GetElementById("Logon").InvokeMember("click") End Sub Private Sub BtnQuery_Click(sender As Object, e As EventArgs) Handles BtnQuery.Click sql = "SELECT [Ticket ID] AS Ticket_ID , [Foundstone] AS Foundstone, [ID] AS ID FROM [Table MAIN] WHERE ([Ticket Days OverDue] >= 0)" 'define the query da = New OleDb.OleDbDataAdapter(sql, con) da.Fill(ds, "MAIN") If ds.Tables("MAIN").Rows.Count > 0 Then TxtRows.Text = ds.Tables("MAIN").Rows.Count maxrows = Val(TxtRows.Text.ToString) End If For i = 0 To maxrows - 1 If i >= 0 Then result = ds.Tables("MAIN").Rows(i).Item("Ticket_ID") WebBrowser1.Navigate("https://fs-enterprise.my.private.url/remediation/ticket.exp?ticket=" & result) Do While WebBrowser1.ReadyState <> WebBrowserReadyState.Complete Application.DoEvents() Loop WebBrowser1.AllowNavigation = True '<div id="MessageGood_0" class="mvm-status-message msm-msg msm-msg-img" style="background-image:url(/images/fam/cross.png);">The specified ticket does not exist, or is not currently available.</div> For Each el As HtmlElement In WebBrowser1.Document.GetElementsByTagName("div") If (el.GetAttribute("id").Equals("MessageGood_0")) Then TxtTicket.Text = ds.Tables("MAIN").Rows(i).Item("Ticket_ID") Try Dim cb As New OleDb.OleDbCommandBuilder(da) cb.QuotePrefix = "[" 'allows update if table name or field is a reserved word in MS Access cb.QuoteSuffix = "]" 'allows update if table name or field is a reserved word in MS Access ds.Tables("MAIN").Rows(i).Item("Foundstone") = "NotFound" da.Update(ds, "MAIN") da.UpdateCommand = cb.GetUpdateCommand() 'MsgBox("Ticket Not Found") Catch ex As Exception MsgBox(ex.Message.ToString, , "Error") End Try Else '<input class="boldbutton" type="button" value="Verify" onclick="this.form.knob.value='ReqVerify';this.form.verify.value=1;this.form.submit()"></td> TxtTicket.Text = ds.Tables("MAIN").Rows(i).Item("Ticket_ID") For Each element As HtmlElement In WebBrowser1.Document.GetElementsByTagName("INPUT") If (element.GetAttribute("value").Equals("Verify")) Then element.InvokeMember("click") End If Next End If Next End If Next MessageBox.Show("All Tickets Have Been Processed") Me.Close() con.Close() End Sub End Class
I tried to do some debugging. I am seeing something like a pin in the "ds.Tables("MAIN").Rows(i).Item("Foundstone") = "NotFound" " section if I hover my mouse on the word tables. I can see what I think might be an error??? In order to evaluate an indexed property, the property must be qualified and the arguments must be explicitly supplied by the user. Thoughts? and maybe this has nothing to do with the real issue...
Last edited: