?
Solved

Must declare variable.

Posted on 2006-06-14
5
Medium Priority
?
685 Views
Last Modified: 2008-01-09
I am fairly new to ASP.Net. I am encountering an error:
Must declare the scalar variable "@equipmmenttype".

I am not sure where or how I need to declare this.
Any help would be great. Thanks in advance !!


CODE:

<%@ Page Language="VB" %>
<script runat="server">

    Protected Sub DetailsView1_ItemInserted(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DetailsViewInsertedEventArgs)
   
        If (Not e.Exception Is Nothing) Then

            ErrorMessageLabel.Text = "An error occured while entering this record.  Please verify you have entered data in the correct format."
            e.ExceptionHandled = True
        End If
        GridView1.DataBind()
    End Sub

    Protected Sub DetailsView1_ItemUpdated(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DetailsViewUpdatedEventArgs)
   
        GridView1.DataBind()
    End Sub

    Protected Sub DropDownList1_SelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs)
   
        DetailsView1.ChangeMode(DetailsViewMode.ReadOnly)
    End Sub

    Protected Sub GridView1_SelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs)
   
        DetailsView1.ChangeMode(DetailsViewMode.ReadOnly)
    End Sub

    Protected Sub GridView1_PageIndexChanged(ByVal sender As Object, ByVal e As EventArgs)
   
        DetailsView1.ChangeMode(DetailsViewMode.ReadOnly)
    End Sub

    Protected Sub GridView1_Sorted(ByVal sender As Object, ByVal e As System.EventArgs)
        DetailsView1.ChangeMode(DetailsViewMode.ReadOnly)
    End Sub
   
    Protected Sub GridView1_RowDeleted(ByVal sender As Object, ByVal e As GridViewDeletedEventArgs)
   
        If (Not e.Exception Is Nothing) Then
       
            ErrorMessageLabel.Text = "Failed to DELETE due to foreign key contstraint on the table.  You may only delete rows which have no related records."
            e.ExceptionHandled = True
        End If
    End Sub

    Protected Sub DetailsView1_DataBound(ByVal sender As Object, ByVal e As EventArgs)
   
        If (DetailsView1.CurrentMode = DetailsViewMode.Insert) Then
       
            Dim stateTextBox As TextBox = CType(DetailsView1.Rows(6).Cells(1).Controls(0), TextBox)
            stateTextBox.Text = DropDownList1.SelectedValue
            stateTextBox.Enabled = False
        End If
    End Sub

</script>
<html>
<head id="Head1" runat="server">
  <title>GridView DetailsView Master-Details (Insert)</title>
</head>
<body>
  <form id="form1" runat="server">
    <b>Choose a state:</b>
    <asp:DropDownList ID="DropDownList1" DataSourceID="SqlDataSource2" AutoPostBack="true"
      DataTextField="equipmenttype" runat="server" OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged" />
    <asp:SqlDataSource ID="SqlDataSource2" runat="server" SelectCommand="SELECT DISTINCT [equipmenttype] FROM [equipmenttype]"
      ConnectionString="<%$ ConnectionStrings:BamAdminConnectionString %>" />
    <br />
    <br />
    <table>
      <tr>
        <td valign="top">
          <asp:GridView ID="GridView1" AllowSorting="True" AllowPaging="True" runat="server"
            DataSourceID="SqlDataSource1" DataKeyNames="id"
            AutoGenerateColumns="False" Width="500px" SelectedIndex="0" OnSelectedIndexChanged="GridView1_SelectedIndexChanged" OnPageIndexChanged="GridView1_PageIndexChanged" OnRowDeleted="GridView1_RowDeleted" OnSorted="GridView1_Sorted">
            <Columns>
              <asp:CommandField ShowSelectButton="true" ShowDeleteButton="true" />
              <asp:BoundField DataField="id" HeaderText="id" ReadOnly="True" SortExpression="id" />
              <asp:BoundField DataField="equipmenttype" HeaderText="type" SortExpression="equipmenttype" />
              <asp:BoundField DataField="make" HeaderText="make" SortExpression="make" />
              <asp:BoundField DataField="model" HeaderText="model" SortExpression="model" />
              <asp:BoundField DataField="serial" HeaderText="serial" SortExpression="serial" />
              <asp:BoundField DataField="owner" HeaderText="owner" SortExpression="owner" />
              <asp:BoundField DataField="name" HeaderText="name" SortExpression="name" />
            </Columns>
          </asp:GridView>
          <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:BamAdminConnectionString %>"
            SelectCommand="SELECT [id], [equipmenttype], [make], [model], [serial], [owner], [name] FROM [hardwareinventory] WHERE ([equipmmenttype] = @equipmmenttype)"
            DeleteCommand="DELETE FROM [hardwareinventory] WHERE [id] = @id">
            <SelectParameters>
              <asp:ControlParameter ControlID="DropDownList1" Name="equipmenttype" PropertyName="SelectedValue"
                Type="String" />
            </SelectParameters>
          </asp:SqlDataSource>
        </td>
        <td valign="top">
          <asp:DetailsView AutoGenerateRows="False" DataKeyNames="id" DataSourceID="SqlDataSource3"
            HeaderText="Author Details" ID="DetailsView1" runat="server" Width="275px" OnItemUpdated="DetailsView1_ItemUpdated" OnItemInserted="DetailsView1_ItemInserted" OnDataBound="DetailsView1_DataBound">
            <Fields>
              <asp:BoundField DataField="id" HeaderText="id" ReadOnly="True" SortExpression="id" />
              <asp:BoundField DataField="equipmenttype" HeaderText="type" SortExpression="equipmenttype" />
              <asp:BoundField DataField="make" HeaderText="make" SortExpression="make" />
              <asp:BoundField DataField="model" HeaderText="model" SortExpression="model" />
              <asp:BoundField DataField="serial" HeaderText="address" SortExpression="serial" />
              <asp:BoundField DataField="owner" HeaderText="city" SortExpression="owner" />
              <asp:CommandField ShowEditButton="True" ShowInsertButton="True" />
            </Fields>
          </asp:DetailsView>
          <asp:SqlDataSource ID="SqlDataSource3" runat="server" ConnectionString="<%$ ConnectionStrings:BamAdminConnectionString %>"
            SelectCommand="SELECT [id], [equipmenttype], [make], [model], [serial], [owner], [name] FROM [hardwareinventory] WHERE ([id] = @id)"
            UpdateCommand="UPDATE [hardwareinventory] SET [equipmenttype] = @equipmenttype, [make] = @make, [model] = @model, [serial] = @serial, [owner] = @owner, [name] = @name WHERE [id] = @id"
            InsertCommand="INSERT INTO [hardwareinventory] ([equipmenttype], [make], [model], [serial], [owner], [name]) VALUES (@equipmenttype, @make, @model, @serial, @owner, @name)">
            <SelectParameters>
              <asp:ControlParameter ControlID="GridView1" Name="id" PropertyName="SelectedValue"
                Type="String" />
            </SelectParameters>
            <UpdateParameters>
              <asp:Parameter Name="equipmenttype" Type="String" />
              <asp:Parameter Name="make" Type="String" />
              <asp:Parameter Name="model" Type="String" />
              <asp:Parameter Name="serial" Type="String" />
              <asp:Parameter Name="owner" Type="String" />
               <asp:Parameter Name="id" Type="String" />
            </UpdateParameters>
            <InsertParameters>
              <asp:Parameter Name="equipmenttype" Type="String" />
              <asp:Parameter Name="make" Type="String" />
              <asp:Parameter Name="model" Type="String" />
              <asp:Parameter Name="serial" Type="String" />
              <asp:Parameter Name="owner" Type="String" />
              <asp:Parameter Name="name" Type="String" />
            </InsertParameters>
          </asp:SqlDataSource>
        </td>
      </tr>
    </table>
    <br />
    <asp:Label ID="ErrorMessageLabel" EnableViewState="false" runat="server" />
  </form>
</body>
</html>
0
Comment
Question by:-cr-
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
5 Comments
 
LVL 20

Accepted Solution

by:
REA_ANDREW earned 2000 total points
ID: 16901703
I think it is just a small spelling error

@equipmmenttype

and then you define this parameter as

equipmenttype

notice the extra m in the first
0
 
LVL 7

Expert Comment

by:pradeepsudharsan
ID: 16901965
Hai  
you put 2 m's instead of single 'm'
error lines
SelectCommand="SELECT [id], [equipmenttype], [make], [model], [serial], [owner], [name] FROM [hardwareinventory] WHERE ([equipmmenttype] = @equipmmenttype)"

Regards

Pradeep
0
 
LVL 20

Expert Comment

by:REA_ANDREW
ID: 16901985
/\ Look at my post ;-)
0
 

Author Comment

by:-cr-
ID: 16902206
Damn. I thought i was going crazy. It was a late night and earlymorning...Thanks I will fix this typo.
0
 
LVL 20

Expert Comment

by:REA_ANDREW
ID: 16904209
did this work for you?
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Sometimes in DotNetNuke module development you want to swap controls within the same module definition.  In doing this DNN (somewhat annoyingly) swaps the Skin and Container definitions to the default admin selections.  To get around this you need t…
IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …

650 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question