2 Replies - 1658 Views - Last Post: 11 April 2014 - 05:38 AM Rate Topic: -----

#1 jonnyp22  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 10
  • Joined: 26-March 14

Using variables instead of hard coded values- help please

Posted 09 April 2014 - 08:04 AM

I'm new to ASP.NET development and I am having a hard time including variables for a text box and calender on my web form. I'm using Visual Studio 2008 so I'm not sure if that will make a difference. I've programmed the button so it works when hard-coded values are entered, but I do not know how to use variables so that the information is pulled from the text box and calender. There will be a store number entered into the text box, and a date selected from the calender. I need the date format to be mm/dd/yyy when sent to the db. Can anyone help me with converting the hard coded values to defined variables? Much appreciated, here is my code with the hard coded values.

Button Code:

Imports Oracle.DataAccess.Client

Partial Class _Default
    Inherits System.Web.UI.Page

    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim conn As String
        conn = "Data Source=*****;User ID=***;Password=****"
        Dim cmd As String
        cmd = "INSERT INTO hud_missed_sales (org_lvl_child, missing_sales_date) VALUES (50001,to_date('01/01/2014','mm/dd/yyyy'))"
        Dim kk As New OracleConnection(conn)
        kk.Open()
        Dim dc As New OracleCommand(cmd, kk)
        'dc.Parameters.AddWithValue("StoreNumBox", "69")
        'dc.Parameters.AddWithValue("MissingDateCal", "to_date('01/01/2014','mm/dd/yyyy')")
        Dim result As Integer = dc.ExecuteNonQuery()
        kk.Close()
    End Sub
End Class



Page code:

%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Exceptions Webform</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    
    
    
        <h1>
            Exceptions Webform</h1>
        <br />
        <br />
    
    
    
        <asp:Label ID="Label1" runat="server" Text="Store Number:"></asp:Label>
        <asp:TextBox ID="StoreNumBox" runat="server"></asp:TextBox>
    
    
          <asp:RequiredFieldValidator
        id="RequiredFieldValidator1"
        runat="server"
        ControlToValidate="StoreNumBox"
        Display="Static"
        ErrorMessage="Please enter a store number." />

    
    
        <br />
        <br />
        <asp:Label ID="Label2" runat="server" Text="Exceptions Date:"></asp:Label>
        <asp:Calendar ID="MissingDateCal" runat="server"></asp:Calendar>
        <br />
        <asp:Button ID="Button1" runat="server" Text="Submit" onclick="Button1_Click" />
    
    
    
    </div>

    </form>
</body>
</html>

Attached image(s)

  • Attached Image


Is This A Good Question/Topic? 0
  • +

Replies To: Using variables instead of hard coded values- help please

#2 jonnyp22  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 10
  • Joined: 26-March 14

Re: Using variables instead of hard coded values- help please

Posted 10 April 2014 - 06:19 AM

Suggestions?? ...
Was This Post Helpful? 0
  • +
  • -

#3 jonnyp22  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 10
  • Joined: 26-March 14

Re: Using variables instead of hard coded values- help please

Posted 11 April 2014 - 05:38 AM

249 views and not one suggestion?? Starting to question the expertise of the members here..
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1