Note that there are some explanatory texts on larger screens.

plurals
  1. POasp.net variable passing
    primarykey
    data
    text
    <p>I am having an odd accuence when i am trying to get my page loaded value to place into a database after the user submits.</p> <p>When the page loads i have this:</p> <pre><code>Public theProductName As String = "" Dim theProductCategory As String = "" Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load If Not IsPostBack Then LoadProductName() End If End Sub Private Sub LoadProductName() objConn = New MySqlConnection(product.strConnString) objConn.Open() strSQL = "SELECT id, name, category " &amp; _ "FROM product " &amp; _ "WHERE id = 4;" Try objCmd = New MySqlCommand(strSQL, objConn) dtReader = objCmd.ExecuteReader() While dtReader.Read() theProductName = dtReader("name") theProductCategory = dtReader("category") btnSubmit.Text = "Add Item to " &amp; theProductName End While dtReader.Close() dtReader = Nothing objConn.Close() objConn = Nothing Catch ex As Exception MsgBox("LoadProductName: " &amp; ex.Message) End Try End Sub </code></pre> <p>When i check those values on startup of the page they have the correct values and even the submit button has the products name.</p> <p>However, once i got to save it after pushing the button it has that same variable as nothing??</p> <pre><code>Private Sub btnSubmit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSubmit.Click Dim productName As String = theProductName.Replace(" ", "-") Dim imageName As String = productName &amp; "\" &amp; Trim(txtModel.Text) &amp; ".jpg'" Dim theCat as String = theProductCategory End Sub </code></pre> <p><strong>productName</strong> here is nothing as is <strong>theCat</strong></p> <p>What could i be overlooking?</p>
    singulars
    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.
 

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