Wrox Home  
Search P2P Archive for: Go

  Return to Index  

aspx_beginners thread: Desperate!!! Please Help


Message #1 by "Tim Farrell" <timothy.farrell@c...> on Thu, 6 Jun 2002 20:15:12
Tim writes:

I have a form with a date field on it to be submitted into a sql db.  

Here is the script:
<script language="VB" runat="server">

    Dim MyConnection As SqlConnection

    Sub Page_Load(Sender As Object, E As EventArgs) 

        MyConnection = New SqlConnection
("server=ntphoenix;database=plan;uid=sa;pwd=;")

        If Not (IsPostBack)
            BindGrid()
        End If
    End Sub

    Sub AddLineItem_Click(Sender As Object, E As EventArgs) 

        Dim DS As DataSet
        Dim MyCommand As SqlCommand

        If week_ending Is "" Or ddl_name.DataValueField = "" 

          Message.InnerHtml = "You must complete Week Ending and Name 
Fields"
          Message.Style("color") = "red"
          BindGrid()
        End If

        Dim InsertCmd As String = "insert into Week_Ending (week_ending) 
values (@week_ending)"

MyCommand = New SqlCommand(InsertCmd, MyConnection)

        MyCommand.Parameters.Add(New SqlParameter("@Week_Ending", 
SqlDbType.smalldatetime, 4))
        MyCommand.Parameters("@Week_Ending").Value = Server.HtmlEncode
(week_ending.Value)

MyCommand.Connection.Open()

        Try 
            MyCommand.ExecuteNonQuery()
            Message.InnerHtml = "<b>Record Added</b><br>" & 
InsertCmd.ToString()

End Try

        MyCommand.Connection.Close()
</script>

Here is the html side of the control:

<tr class="tabletext">
<td noWrap style="WIDTH: 100px">Week Ending:</td>
<td><asp:TextBox ID="week_ending" Runat="server"></asp:TextBox></td>
</tr>

The Problem:
I am getting a compilation error from the server as follows.
'Value' is not a member of 'System.Web.UI.WebControls.TextBox'.
If I add the parameter value="" to the control it doesn't recognize it.

Question:
How do I get the value of the control to submit to the database?

Thank you very much for your time!

Sincerely,

Tim





  Return to Index