Note that there are some explanatory texts on larger screens.

plurals
  1. POReferencing a text-box through an object name in VisualBasic.NET
    primarykey
    data
    text
    <p>How can I possibly use the value of an object (e.g. a string), to then reference to the name of a text-box on a form in Visual Basic .net? I'm hoping to be able to grab information from a SQL database and put them in corresponding text-boxes, based on their names on the form (e.g. put the information for the field fSynopsis in the text-box txtSynopsis.Text).</p> <p>The code below is what I'm using at the moment.</p> <pre><code>Private Sub DataGridView1_CellMouseClick(sender As Object, e As DataGridViewCellMouseEventArgs) Handles dgvResults.CellMouseClick ' Set values in the text boxes to both corresponding to the film. Dim strFields() As String = {"fSynopsis", "fGenre", "fSynopsis", "fAgeRating", "fActorsActresses", "fWebRating", "fNoReservations", "fWeeksRunning"} 'Create an array containing the names of the fields in the database. Dim Con = New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=ApplicationData.accdb;Persist Security Info=False;") Con.Open() 'Open the connection Dim Cmd As New OleDbCommand(StringBuilderCommand("fAgeRating", "Films", dgvResults.CurrentCell.Value, "fName"), Con) 'Create a string by calling the StringBuilderCommand to combine the parameters together with quotes. Cmd.CommandType = CommandType.Text Dim Rdr As OleDbDataReader = Cmd.ExecuteReader() Dim intCount As Integer = 0 ' Create a loop variable. Do While Rdr.Read() ' While this statement is 'TRUE', e.g. there is a valid record. strResult = "txt" &amp; strFields(intCount).Replace("f", "") 'Remove any instances of 'f', e.g. the prefix of the string. strResult.Text = Rdr.Item(strFields(intCount).ToString) 'Set the text-box to the correct value from the database. ' This will allow me to go through several text boxes, and grab their corresponding values from the database. intCount += 1 Loop </code></pre> <p>I'd really appreciate any help available, thank-you!</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload