locked
My VB code does recognized the aspx variables RRS feed

  • Question

  • User1120668264 posted

    I can't seem to use my aspx information in my vb.

    Here is the ASPX.

    InsertItemTemplate>

    EmpId:

     

    <asp:DropDownList ID="EmpIdTextBox" runat="server" Text='<%# Bind("EmpId") %>'

    DataSourceID="AccessDataSource1" DataTextField="Expr1" DataValueField="EmpID">

    </asp:DropDownList>

     

     

     

    <asp:AccessDataSource ID="AccessDataSource1" runat="server"

    DataFile="~/App_Data/MMN.mdb"

    SelectCommand="SELECT EmpID, LastName &amp; ', ' &amp; FirstName AS Expr1 FROM EmployeeTbl ORDER BY LastName &amp; ', ' &amp; FirstName">

    </asp:AccessDataSource>

     

     

     

    <br />

    DateWorked:

    <asp:TextBox ID="DateWorkedTextBox" runat="server"

    Text='<%# Bind("DateWorked") %>'

    ontextchanged="DateWorkedTextBox_TextChanged" />

    <cc1:CalendarExtender ID="DateWorkedTextBox_CalendarExtender" runat="server"

    Enabled="True" TargetControlID="DateWorkedTextBox">

    </cc1:CalendarExtender>

    <br />

    HrsWorked:

    <asp:TextBox ID="HrsWorkedTextBox" runat="server"

    Text='<%# Bind("HrsWorked") %>' />

    <br />

    Here is the VB

    Dim con As New System.Data.OleDb.OleDbConnection

    Dim myPath As String

    myPath = Server.MapPath("~/App_Data/MMN.mdb")

    con.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0; Data source=" & myPath & ";"

    Dim myCommand As New System.Data.OleDb.OleDbCommandDim hold As String = DateWorkedTextBox.text

    MsgBox(DateWorkedTextBox.text)

    myCommand.CommandText = "insert into ReliefSchedule(EmpId, DateWorked) values(" '" & EmpIdTextBox.text & "'" ,#02/01/2009#)"

    myCommand.Connection = con

    con.Open()

    The error msg is not delclared.

    Sunday, February 15, 2009 11:55 AM

Answers

  • User1589032278 posted

    repaire your command text line to

     

    myCommand.CommandText = "insert into ReliefSchedule(EmpId, DateWorked) values( '" & EmpIdTextBox.text & "' ,'02/01/2009')"
     
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, February 15, 2009 11:12 PM
  • User-990694832 posted

    I would suggest that system.text.stringbuilder is used to build the strings

    sb.append("insert into ReliefSchedule(EmpId, DateWorked) values('")
    sb.append(EmpIdTextBox.text)
    sb.append("',#02/01/2009#)"

    myCommand.CommandText = sb.tostring()

    Hope this helps
    DK

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, February 18, 2009 8:48 AM

All replies

  • User1589032278 posted

    repaire your command text line to

     

    myCommand.CommandText = "insert into ReliefSchedule(EmpId, DateWorked) values( '" & EmpIdTextBox.text & "' ,'02/01/2009')"
     
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, February 15, 2009 11:12 PM
  • User-990694832 posted

    I would suggest that system.text.stringbuilder is used to build the strings

    sb.append("insert into ReliefSchedule(EmpId, DateWorked) values('")
    sb.append(EmpIdTextBox.text)
    sb.append("',#02/01/2009#)"

    myCommand.CommandText = sb.tostring()

    Hope this helps
    DK

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, February 18, 2009 8:48 AM