locked
SQL Data Source is not pulling parameters RRS feed

  • Question

  • User1537775908 posted

    Hello,

    I have a web form in Visual Studio 2012 where i have this SQL Data Source:

        <asp:SqlDataSource ID="AssetSqlDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:meindbConnectionString %>"

            InsertCommand="INSERT INTO ASSETS (USERNAME, ASSETTAG,
            SERIALNUMBER, DEPT, CATEGORY, ITEMDESC, MODEL, ISSUEDATE, ISSUEDBY,
            TOTALVALUE, ACCESSORIES, ISSUECONDITION, NOTES, CREATEBY, CREATEDATE)
            SELECT @USERNAME2, ASSETTAG, SERIALNUMBER, DEPT, CATEGORY, ITEMDESC, MODEL,
            ISSUEDATE, ISSUEDBY, TOTALVALUE, ACCESSORIES, ISSUECONDITION, NOTES,
            CREATEBY, CREATEDATE FROM ASSETS WHERE USERNAME = @USERNAME">

            <InsertParameters>

                <asp:ControlParameter ControlID="ContentPlaceHolder1$WebGroupBox1$FormView1$UserWebDropDown" Name="USERNAME" PropertyName="SelectedValue" Type="String" />
                <asp:ControlParameter ControlID="ContentPlaceHolder1$WebGroupBox1$FormView1$WebDropDown1" Name="USERNAME2" PropertyName="SelectedValue" Type="String" />
                <asp:Parameter Name="ASSETTAG" Type="String" />
                <asp:Parameter Name="SERIALNUMBER" Type="String" />
                <asp:Parameter Name="DEPT" Type="String" />
                <asp:Parameter Name="ITEMDESC" Type="String" />
                <asp:Parameter Name="MODEL" Type="String" />
                <asp:Parameter Name="ISSUEDATE" Type="DateTime" />
                <asp:Parameter Name="ISSUEDBY" Type="String" />
                <asp:Parameter Name="CATEGORY" Type="String" />
                <asp:Parameter Name="TOTALVALUE" Type="Int32" />
                <asp:Parameter Name="ACCESSORIES" Type="String" />
                <asp:Parameter Name="ISSUECONDITION" Type="String" />
                <asp:Parameter Name="NOTES" Type="String" />
                <asp:Parameter Name="CREATEDATE" Type="DateTime" />
                <asp:ControlParameter ControlID="UsernameHiddenField" Name="CREATEBY" PropertyName="Value" Type="String" />
                <asp:Parameter Direction="Output" Name="ID" Type="Int32" />

            </InsertParameters>
            <SelectParameters>
                <asp:ControlParameter ControlID="EditIDHiddenField" Name="ID" PropertyName="Value" Type="Int32" />
            </SelectParameters>
        </asp:SqlDataSource>

    This data source is meant to grab one name from each of the drop down lists and copy the rows of data from user 1 to user 2. Whenever I execute this command, it gives me the right amount of affected rows but nothing shows up in the database. If I replace the parameters with valid usernames it runs fine and data is copied into my DB. Can someone help me with this issue?

    Thanks

    Friday, September 15, 2017 12:09 PM

All replies

  • User-707554951 posted

    Hi kmizle,

    Are you sure that the database you INSERT into and the database you're looking at with Server Explorer are the same one?

    Remember, we're talking about a file-based DB here (SQL Server CE). So it could be that you're inserting into a copy of your DB and then look at the (unchanged) original.

    Make double sure that your connection string really points to the database you're looking at with Server Explorer!

    Best regards

    Cathy

    Monday, September 18, 2017 2:22 AM
  • User1537775908 posted

    Thank you for the response Cathy, but yes I am sure i'm looking at the right DB. If I replace @USERNAME and @USERNAME2 with usernames it actually shows up in my database. I'm just having trouble with my command pulling the parameters

    Tuesday, September 19, 2017 6:28 PM