Results 1 to 3 of 3

Thread: How to Automatically fill out web forms

  1. #1

    Thread Starter
    Member
    Join Date
    Jul 2007
    Location
    Silly Clone Valley CA
    Posts
    47

    How to Automatically fill out web forms

    I need to make a project that automatically connects to an internal server that has a web interface, fill out specific information, including picking items from a drop down list, textboxes, and then pressing the enter button.

    Is this something I can handle in Vb 2005? or should I do it in Perl?

    I believe the form is done in asp. Unfortunately the team that handles the service and servers are too busy to help me, so I need to access it from a user standpoint.

    Even if you don't know how to do this, if you can point me in what direction I need to look for information that would be helpfull.

    Thanks!

  2. #2
    Lively Member tamjap's Avatar
    Join Date
    Jun 2007
    Posts
    99

    Re: How to Automatically fill out web forms

    Kleinma has a good example on how to do this in the code bank here. He uses a COM object named SHDocVW. I have tried to do this in the past, and it works well, though frames appear to be inaccessible in .NET (from my experience) and now that my new program is hosted on a new Windows Server 2003 server, the Navigate command finishes loading the site. My code has worked on other systems, though, so I would be interested in learning what results you get.

  3. #3
    Frenzied Member SomethinCool's Avatar
    Join Date
    Jan 2001
    Location
    Malvern, PA
    Posts
    1,407

    Re: How to Automatically fill out web forms

    I don't know if this can help you or not but...

    This is some of my code on how I retrieve data from a SQL Database and then input the data into a ListBox:

    vb Code:
    1. Private Sub refreshGroupList()
    2.         lstEmailGroups.Items.Clear()
    3.  
    4.         Dim sqlConn As New OleDb.OleDbConnection(sqlConnString)
    5.         Dim sqlStatement As String = "SELECT GroupName FROM EmailGroups ORDER BY GroupName"
    6.         Dim sqlCmdGroups As New OleDb.OleDbCommand(sqlStatement, sqlConn)
    7.         Dim groupDS As New DataSet
    8.         Dim groupDT As New DataTable
    9.         Dim sqlDA As New OleDb.OleDbDataAdapter
    10.  
    11.         Try
    12.             sqlConn.Open()
    13.  
    14.             sqlDA.SelectCommand = sqlCmdGroups
    15.  
    16.             groupDS.Tables.Add(groupDT)
    17.             sqlDA.Fill(groupDT)
    18.         Catch ex As Exception
    19.             Response.Write("Error connecting to database! Please contact your administrator. " & vbNewLine & ex.Message)
    20.         Finally
    21.             sqlConn.Close()
    22.         End Try
    23.  
    24.         For Each row As DataRow In groupDS.Tables(0).Rows
    25.             lstEmailGroups.Items.Add(Trim(row("GroupName")))
    26.         Next
    27.     End Sub

    And here is code that adds data retrieved from a SQL Database to textboxes and drop down menus:

    vb Code:
    1. Private Sub btnEditData_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnEditData.Click
    2.  
    3.         lstBranch.ClearSelection()
    4.         lstDepartment.ClearSelection()
    5.  
    6.         Dim counter As Integer
    7.         Dim userID As Integer
    8.  
    9.         userID = lstUsers.SelectedItem.Value
    10.  
    11.         Dim sqlConn As New OleDb.OleDbConnection(sqlConnString)
    12.         Dim sqlStatement As String = "SELECT * FROM Directory WHERE UserID = " & UserID
    13.         Dim sqlDA As New OleDb.OleDbDataAdapter
    14.         Dim sqlCommand As New OleDb.OleDbCommand(sqlStatement, sqlConn)
    15.  
    16.         Try
    17.             sqlConn.Open()
    18.  
    19.             sqlDA.SelectCommand = sqlCommand
    20.  
    21.             DS.Tables.Add(DT)
    22.             sqlDA.Fill(DT)
    23.  
    24.             txtFirstName.Text = DS.Tables(0).Rows(0)("First_Name").ToString
    25.             txtLastName.Text = DS.Tables(0).Rows(0)("Last_Name").ToString
    26.             txtNickname.Text = DS.Tables(0).Rows(0)("Nickname").ToString
    27.             txtNickname2.Text = DS.Tables(0).Rows(0)("Nickname2").ToString
    28.             txtNickname3.Text = DS.Tables(0).Rows(0)("Nickname3").ToString
    29.             txtExtension.Text = DS.Tables(0).Rows(0)("Extension").ToString
    30.             txtDID.Text = DS.Tables(0).Rows(0)("Direct_Dial").ToString
    31.             txtCellNum.Text = DS.Tables(0).Rows(0)("Cell_Number").ToString
    32.             txtDC.Text = DS.Tables(0).Rows(0)("DirectConnect").ToString
    33.             txtSalesNum.Text = DS.Tables(0).Rows(0)("Sales_Number").ToString
    34.             txtEmailAddress.Text = DS.Tables(0).Rows(0)("Email").ToString
    35.             txtSignOn.Text = DS.Tables(0).Rows(0)("Sign_On").ToString
    36.  
    37.             counter = 0
    38.  
    39.             For counter = 0 To lstBranch.Items.Count - 1
    40.                 If lstBranch.Items(counter).Text = DS.Tables(0).Rows(0)("Branch").ToString Then
    41.                     lstBranch.Items(counter).Selected = True
    42.                 End If
    43.  
    44.             Next
    45.  
    46.             counter = 0
    47.  
    48.             For counter = 0 To lstDepartment.Items.Count - 1
    49.                 If lstDepartment.Items(counter).Text = DS.Tables(0).Rows(0)("Department").ToString Then
    50.                     lstDepartment.Items(counter).Selected = True
    51.                 End If
    52.             Next
    53.  
    54.             sqlCommand.Dispose()
    55.             DS.Dispose()
    56.             DT.Dispose()
    57.  
    58.         Catch ex As Exception
    59.             Response.Write("<script>alert(""Error connecting to the database. Please contact your administrator." & vbNewLine & ex.Message & """);</script>")
    60.         Finally
    61.             sqlConn.Close()
    62.         End Try
    63.     End Sub

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width