简体   繁体   English

SQL 存储过程未收到从 VB 传递的参数

[英]SQL Stored Procedure not recieving Parameter passed from VB

So I've reached a wall with my project I've been working on.所以我已经完成了我一直在做的项目。 I'm trying to get a search form to function by letting the user enter data into each form field, then do a search for all specific fields.我试图通过让用户在每个表单字段中输入数据,然后搜索所有特定字段来使搜索表单发挥作用。 This should return all rows that are applicable.这应该返回所有适用的行。

Whats happening is, when the user runs the search, the text is taken from the form field, and brought into VB to be validated and then pushed into a stored procedure.发生的事情是,当用户运行搜索时,文本从表单字段中取出,并带入 VB 进行验证,然后推送到存储过程中。 The stored procedure however, is not seeing the parameters that are being passed over.但是,存储过程没有看到正在传递的参数。 I've tried a few different methods of trying to get the data, but it's just not happening.我尝试了几种不同的方法来尝试获取数据,但都没有发生。 When I run the code with a break point, I can SEE that the text is being brought into the VB just fine, but it is not being passed as a parameter (in fact, I can't find anything in the breakpoint window that says my parameter is being generated)当我用断点运行代码时,我可以看到文本被很好地引入到 VB 中,但它没有作为参数传递(事实上,我在断点窗口中找不到任何说我的参数正在生成)

The error I am receiving is:我收到的错误是:

Procedure or function 'SearchFarmStand' expects parameter '@Farm_Business_Name', which was not supplied.过程或函数“SearchFarmStand”需要未提供的参数“@Farm_Business_Name”。

I have tried Googling for several hours to fix this with no success我已经尝试了几个小时的谷歌搜索来解决这个问题,但没有成功

I've made a lot of edits in hopes that I could get it to work, but I have not been successful.我已经做了很多编辑,希望我能让它工作,但我没有成功。 I've tried setting the default value on the parameters to NULL but that still doesn't get the parameters, although it does go through with the procedure, it just returns nothing.我已经尝试将参数的默认值设置为 NULL 但仍然没有得到参数,尽管它确实通过了该过程,但它什么也不返回。 On the VB side of things, I've also tried many different ways to declare the parameters using both cmd.Parameter.Add and cmd.Parameter.AddWithValue.在 VB 方面,我还尝试了许多不同的方法来使用 cmd.Parameter.Add 和 cmd.Parameter.AddWithValue 来声明参数。 My code shows my most recent attempt at getting the parameter.我的代码显示了我最近获取参数的尝试。

Any help would be AWESOME as I'm stuck completely任何帮助都会很棒,因为我完全被卡住了

The following is my code:以下是我的代码:

WebForm2.aspx WebForm2.aspx

<form id="SearchForm" runat="server">
    <asp:Panel ID="SearchPanel" runat="server">
            <div role="group" class="threecolumn-container">
                <div class="threecolumn" style="order: 1;" runat="server">
                    Farm/Business Name:<br /><asp:Textbox CssClass="flex-stretch" ID="FarmBusinessNameSearch" runat="server"></asp:Textbox><br />
                    Farm/Business Owner:<br /><asp:Textbox CssClass="flex-stretch" ID="FarmOwnersSearch" runat="server"></asp:Textbox><br />
                    Full Address:<br /><asp:Textbox CssClass="flex-stretch" ID="FullFarmAddressSearch" runat="server"></asp:Textbox><br />
                    Address 1:<br /><asp:Textbox CssClass="flex-stretch" ID="Address1Search" runat="server"></asp:Textbox><br />
                    City:<br /><asp:Textbox CssClass="flex-stretch" ID="CitySearch" runat="server"></asp:Textbox><br />
                    State:<br /><asp:Textbox CssClass="flex-stretch" ID="StateSearch" runat="server"></asp:Textbox>
                </div>
                <div class="threecolumn" style="order: 2;"  runat="server">
                    Zip:<br /><asp:Textbox CssClass="flex-stretch" ID="ZipSearch" runat="server"></asp:Textbox><br />
                    County:<br /><asp:Textbox CssClass="flex-stretch" ID="CountySearch" runat="server"></asp:Textbox><br />
                    Phone:<br /><asp:Textbox CssClass="flex-stretch" ID="PhoneSearch" runat="server"></asp:Textbox><br />
                    Website:<br /><asp:Textbox CssClass="flex-stretch" ID="WebsiteSearch" runat="server"></asp:Textbox><br />
                    Email:<br /><asp:Textbox CssClass="flex-stretch" ID="EmailSearch" runat="server"></asp:Textbox>
                </div>
                <div class="threecolumn" style="order: 3;"  runat="server">
                    Dates Open:<br /><asp:Textbox CssClass="flex-stretch" ID="DatesOpenSearch" runat="server"></asp:Textbox><br />
                    Dates Closed:<br /><asp:Textbox CssClass="flex-stretch" ID="DatesClosedSearch" runat="server"></asp:Textbox><br />
                    Stand Open Time:<br /><asp:Textbox CssClass="flex-stretch" ID="StandOpenTimeSearch" runat="server"></asp:Textbox><br />
                    Stand Closed Time:<br /><asp:Textbox CssClass="flex-stretch" ID="StandCloseTimeSearch" runat="server"></asp:Textbox><br />
                    BIO:<br /><asp:Textbox CssClass="flex-stretch" ID="BIOSearch" runat="server"></asp:Textbox><br />
                    Open Ended Response:<br /><asp:Textbox CssClass="flex-stretch" ID="OpenEndedResponseSearch" runat="server"></asp:Textbox>
                </div>
            </div>
            <div class="clearfix"></div>
            <div role="group" class="fourcolumn-container">
                <div class="fourcolumn" style="order: 1;" runat="server">
                        <asp:CheckBox ID="VegetablesSearch" Text="Vegetables" runat="server"></asp:CheckBox><br />
                        <asp:CheckBox ID="GrainsSearch" Text="Grains" runat="server"></asp:CheckBox><br />
                        <asp:CheckBox ID="BreadBakedGoodsSearch" Text="Bread/Baked Goods" runat="server"></asp:CheckBox><br />
                        <asp:CheckBox ID="EggsSearch" Text="Eggs" runat="server"></asp:CheckBox><br />
                        <asp:CheckBox ID="MilksRawMilkSearch" Text="Milks/Raw Milk" runat="server"></asp:CheckBox><br />
                        <asp:CheckBox ID="CheeseSearch" Text="Cheese" runat="server"></asp:CheckBox>
                </div>
                <div class="fourcolumn" style="order: 2;" runat="server">
                        <asp:CheckBox ID="CiderApplesSearch" Text="Cider/Apples" runat="server"></asp:CheckBox><br />
                        <asp:CheckBox ID="HoneySearch" Text="Honey" runat="server"></asp:CheckBox><br />
                        <asp:CheckBox ID="WineHardCiderSearch" Text="Wine/Hard Cider" runat="server"></asp:CheckBox><br />
                        <asp:CheckBox ID="FruitsSearch" Text="Fruits" runat="server"></asp:CheckBox><br />
                        <asp:CheckBox ID="BerriesSearch" Text="Berries" runat="server"></asp:CheckBox><br />
                        <asp:CheckBox ID="MaplesSearch" Text="Maple Goods" runat="server"></asp:CheckBox>
                </div>
                <div class="fourcolumn" style="order: 3;" runat="server">
                        <asp:CheckBox ID="ChickenSearch" Text="Chicken" runat="server"></asp:CheckBox><br />
                        <asp:CheckBox ID="TurkeySearch" Text="Turkey" runat="server"></asp:CheckBox><br />
                        <asp:CheckBox ID="BeefSearch" Text="Beef" runat="server"></asp:CheckBox><br />
                        <asp:CheckBox ID="PorkSearch" Text="Pork" runat="server"></asp:CheckBox><br />
                        <asp:CheckBox ID="LambSearch" Text="Lamb" runat="server"></asp:CheckBox><br />
                        <asp:CheckBox ID="GoatSearch" Text="Goat" runat="server"></asp:CheckBox>
                </div>
                <div class="fourcolumn" style="order: 4;" runat="server">
                        <asp:CheckBox ID="WoolFiberSearch" Text="Wool Fiber" runat="server"></asp:CheckBox><br />
                        <asp:CheckBox ID="WoodProductsSearch" Text="Wood Products" runat="server"></asp:CheckBox><br />
                        <asp:CheckBox ID="FlowersSearch" Text="Flowers" runat="server"></asp:CheckBox><br />
                        <asp:CheckBox ID="CannedBottledGoodsSearch" Text="Canned/Bottled Goods" runat="server"></asp:CheckBox><br />
                        <asp:CheckBox ID="PlantSeedlingsStartsSearch" Text="Plant Seedlings/Starts" runat="server"></asp:CheckBox><br />
                        <asp:CheckBox ID="PlantsTreesSearch" Text="Plants/Trees" runat="server"></asp:CheckBox><br />
                </div>
            </div>
            <div class="clearfix"></div>
            <div class="onecolumn">
                Other:<br /><asp:Textbox CssClass="flex-stretch" ID="OtherSearch" runat="server"></asp:Textbox>
            </div>
            <div class="clearfix"></div>
            <div role="group" class="twocolumn-container">
                <div class="twocolumn" style="order: 1;" runat="server">
                    Certified Organic:<br /><asp:Textbox CssClass="flex-stretch" ID="CertifiedOrganicSearch" runat="server"></asp:Textbox><br />
                    Organic Certifier:<br /><asp:Textbox CssClass="flex-stretch" ID="OrganicCertifierSearch" runat="server"></asp:Textbox><br />
                    Other Farms Local:<br /><asp:Textbox CssClass="flex-stretch" ID="OtherFarmsLocalSearch" runat="server"></asp:Textbox><br />
                    Suplemental Catagories:<br /><asp:Textbox CssClass="flex-stretch" ID="SupplementalCatagoriesSearch" runat="server"></asp:Textbox><br />
                    Being Operation:<br /><asp:Textbox CssClass="flex-stretch" ID="BeginOperationSearch" runat="server"></asp:Textbox><br />
                    <asp:CheckBox ID="PickYourOwnSearch" Text="Pick Your Own" runat="server"></asp:CheckBox>
                    <br />
                    <asp:CheckBox ID="EBTSearch" Text="EBT" runat="server"></asp:CheckBox>
                </div>
                <div class="twocolumn" style="order: 2;" runat="server">
                    Staffed:<br /><asp:Textbox CssClass="flex-stretch" ID="StaffedSearch" runat="server"></asp:Textbox><br />
                    Customers Peak Season:<br /><asp:Textbox CssClass="flex-stretch" ID="CustomersPeakSeasonSearch" runat="server"></asp:Textbox><br />
                    Customers 2015:<br /><asp:Textbox CssClass="flex-stretch" ID="Customers2015Search" runat="server"></asp:Textbox><br />
                    Customers 2014:<br /><asp:Textbox CssClass="flex-stretch" ID="Customers2014Search" runat="server"></asp:Textbox><br />
                    Percent Self Produced:<br /><asp:Textbox CssClass="flex-stretch" ID="PercentSelfProducedSearch" runat="server"></asp:Textbox><br />
                    <asp:CheckBox ID="SellOtherFarmsSearch" Text="Sell Other Farms" runat="server"></asp:CheckBox>
                    <br />
                    <asp:CheckBox ID="LiabilityInsuranceSearch" Text="Liability Insurance" runat="server"></asp:CheckBox>
                </div>
            </div>
            <div class="clearfix"></div>
        <asp:Button ID="SearchButton" runat="server" Text="Search"/> &ensp; <asp:Button ID="ShowAllButton" runat="server" Text="Show All Farmstands"/>
    </asp:Panel>

Another Panel exists below for displaying my data, as well as another datalist to store the returned search data.下面存在另一个面板用于显示我的数据,以及另一个用于存储返回的搜索数据的数据列表。

Behind Code WebForm2.aspx.VB UPDATED代码 WebForm2.aspx.VB 更新后

Protected Sub SearchClick(ByVal sender As Object, ByVal e As System.EventArgs) Handles SearchButton.Click

    Dim sqlConnection1 As New SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings("FSDATA").ConnectionString)
    Dim cmd As New SqlCommand

    cmd.CommandText = "SearchFarmStand"
    cmd.CommandType = System.Data.CommandType.StoredProcedure
    cmd.Connection = sqlConnection1

    'TEXTBOXES
    Dim Farm_Bussiness_Name As SqlParameter = New SqlParameter(
        "@Farm_Business_Name", SqlDbType.NVarChar, 255)
    Farm_Bussiness_Name.Value = FarmBusinessNameSearch.Text
    cmd.Parameters.Add(Farm_Bussiness_Name)
    Dim Farm_Owners As SqlParameter = New SqlParameter(
        "@Farm_Owners", SqlDbType.NVarChar, 255)
    Farm_Owners.Value = FarmOwnersSearch.Text
    cmd.Parameters.Add(Farm_Owners)
    Dim Full_Farm_Address As SqlParameter = New SqlParameter(
        "@Full_Farm_Address", SqlDbType.NVarChar, 255)
    Full_Farm_Address.Value = FullFarmAddressSearch.Text
    cmd.Parameters.Add(Full_Farm_Address)
    Dim Address_1 As SqlParameter = New SqlParameter(
        "@Address_1", SqlDbType.NVarChar, 255)
    Address_1.Value = Address1Search.Text
    cmd.Parameters.Add(Address_1)
    Dim City As SqlParameter = New SqlParameter(
        "@City", SqlDbType.NVarChar, 255)
    City.Value = CitySearch.Text
    cmd.Parameters.Add(City)
    Dim State As SqlParameter = New SqlParameter(
        "@State", SqlDbType.NVarChar, 255)
    State.Value = StateSearch.Text
    cmd.Parameters.Add(State)
    If DatesOpenSearch.Text <> "" Then
        Dim time As DateTime = DateTime.Parse(DatesOpenSearch.Text)
        Dim Dates_Open As SqlParameter = New SqlParameter(
        "@Dates_Open", SqlDbType.DateTime)
        Dates_Open.Value = time
        cmd.Parameters.Add(Dates_Open)
    Else
        Dim Dates_Open As SqlParameter = New SqlParameter(
        "@Dates_Open", SqlDbType.DateTime)
        Dates_Open.Value = DBNull.Value
        cmd.Parameters.Add(Dates_Open)
    End If
    If DatesClosedSearch.Text <> "" Then
        Dim time As DateTime = DateTime.Parse(DatesClosedSearch.Text)
        Dim Dates_Closed As SqlParameter = New SqlParameter(
        "@Dates_Closed", SqlDbType.DateTime)
        Dates_Closed.Value = time
        cmd.Parameters.Add(Dates_Closed)
    Else
        Dim Dates_Closed As SqlParameter = New SqlParameter(
        "@Dates_Closed", SqlDbType.DateTime)
        Dates_Closed.Value = DBNull.Value
        cmd.Parameters.Add(Dates_Closed)
    End If

    ... More Textbox Dims...

    'CHECKBOXES
    If VegetablesSearch.Checked = "True" Then
        Dim Vegetables As SqlParameter = New SqlParameter(
        "@Vegetables", SqlDbType.Bit)
        Vegetables.Value = VegetablesSearch.Checked
        cmd.Parameters.Add(Vegetables)
    Else
        Dim Vegetables As SqlParameter = New SqlParameter(
        "@Vegetables", SqlDbType.Bit)
        Vegetables.Value = VegetablesSearch.Checked
        cmd.Parameters.Add(Vegetables)
    End If
    If GrainsSearch.Checked = "True" Then
        Dim Grains As SqlParameter = New SqlParameter(
        "@Grains", SqlDbType.Bit)
        Grains.Value = GrainsSearch.Checked
        cmd.Parameters.Add(Grains)
    Else
        Dim Grains As SqlParameter = New SqlParameter(
        "@Grains", SqlDbType.Bit)
        Grains.Value = GrainsSearch.Checked
        cmd.Parameters.Add(Grains)
    End If

    ...More Checkbox Dims...

    DataList1.Visible = "False"
    DataList2.Visible = "True"
    sqlConnection1.Open()
    cmd.ExecuteNonQuery()
    sqlConnection1.Close()
End Sub

Stored Procedure SearchFarmStand.sql UPDATED存储过程 SearchFarmStand.sql 更新

USE [FSDATA3]
GO    
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[SearchFarmStand]
@Farm_Business_Name nvarchar(255),
@Farm_Owners nvarchar(255),
@Full_Farm_Address nvarchar(255),
@Address_1 nvarchar(255),
@City nvarchar(255),
@State nvarchar(255),
@Zip nvarchar(5),
@County nvarchar(255),
@Phone nvarchar(255),
@Website nvarchar(255),
@Email nvarchar(255),
@Dates_Open datetime = NULL,
@Dates_Closed datetime = NULL,
@Stand_Open_Time nvarchar(255),
@Stand_Close_Time nvarchar(255),
@BIO nvarchar(MAX),
@Open_Ended_Response nvarchar(255),
@Vegetables bit,
@Grains bit,
@Bread_Baked_Goods bit,
@Eggs bit,
@Milks_Raw_Milk bit,
@Cheese bit,
@Cider_Apples bit,
@Honey bit,
@Wine_Hard_Cider bit,
@Fruits bit,
@Berries bit,
@Chicken bit,
@Turkey bit,
@Beef bit,
@Pork bit,
@Lamb bit,
@Goat bit,
@Wool_Fiber bit,
@Wood_Products bit,
@Flowers bit,
@Canned_Bottled_Goods bit,
@Maples bit,
@Plant_Seedlings_Starts bit,
@Plants_Trees bit,
@Other nvarchar(255),
@Pick_Your_Own bit,
@Certified_Organic nvarchar(255),
@Organic_Certifier nvarchar(255),
@Sell_Other_Farms bit,
@Other_Farms_Local nvarchar(255),
@Supplemental_Catagories nvarchar(255),
@Begin_Operation float,
@Staffed nvarchar(255),
@Liability_Insurance bit,
@Customers_Peak_Season float,
@Customers_2015 float,
@Customers_2014 float,
@Percent_Self_Produced nvarchar(255),
@EBT bit
AS
BEGIN
SET NOCOUNT ON;

DECLARE @ODate DATETIME
DECLARE @CDate DATETIME

SET @ODate = ISNULL(@Dates_Open, GETDATE())
SET @CDate = ISNULL(@Dates_Closed, GETDATE())

SELECT * FROM FSDATA WHERE
Farm_Business_Name LIKE '%' + ISNULL(@Farm_Business_Name, Farm_Business_Name) + '%' and
Farm_Owners LIKE '%' + ISNULL(@Farm_Owners, Farm_Owners) + '%' and
Full_Farm_Address LIKE '%' + ISNULL(@Full_Farm_Address, Full_Farm_Address) + '%' and
Address_1 LIKE '%' + ISNULL(@Address_1, Address_1) + '%' and
City LIKE '%' + ISNULL(@City, City) + '%' and
State LIKE '%' + ISNULL(@State, State) + '%' and
Zip LIKE '%' + ISNULL(@Zip, Zip) + '%' and
County LIKE '%' + ISNULL(@County, County) + '%' and
Phone LIKE '%' + ISNULL(@Phone, Phone) + '%' and
Website LIKE '%' + ISNULL(@Website, Website) + '%' and
Email LIKE '%' + ISNULL(@Email, Email) + '%' and
Dates_Open = @ODate and
Dates_Closed = @CDate and
Stand_Open_Time LIKE '%' + ISNULL(@Stand_Open_Time, Stand_Open_Time) + '%' and
Stand_Close_Time LIKE '%' + ISNULL(@Stand_Close_Time, Stand_Close_Time) + '%' and
BIO LIKE '%' + ISNULL(@BIO, BIO) + '%' and
Open_Ended_Response LIKE '%' + ISNULL(@Open_Ended_Response, Open_Ended_Response) + '%' and
Vegetables = @Vegetables and
Grains = @Grains and
Bread_Baked_Goods = @Bread_Baked_Goods and
Eggs = @Eggs and
Milks_Raw_Milk = @Milks_Raw_Milk and
Cheese = @Cheese and
Cider_Apples = @Cider_Apples and
Honey = @Honey and
Wine_Hard_Cider = @Wine_Hard_Cider and
Fruits = @Fruits and
Berries = @Berries and
Chicken = @Chicken and
Turkey = @Turkey and
Beef = @Beef and
Pork = @Pork and
Lamb = @Lamb and
Goat = @Goat and
Wool_Fiber = @Wool_Fiber and
Cheese = @Cheese and
Wood_Products = @Wood_Products and
Flowers = @Flowers and
Canned_Bottled_Goods = @Canned_Bottled_Goods and
Maples = @Maples and
Plant_Seedlings_Starts = @Plant_Seedlings_Starts and
Plants_Trees = @Plants_Trees and
Other LIKE '%' + ISNULL(@Other, Other) + '%' and
Pick_Your_Own = @Pick_Your_Own and
Certified_Organic LIKE '%' + ISNULL(@Certified_Organic, Certified_Organic) + '%' and
Organic_Certifier LIKE '%' + ISNULL(@Organic_Certifier, Organic_Certifier) + '%' and
Sell_Other_Farms = @Sell_Other_Farms and
Other_Farms_Local LIKE '%' + ISNULL(@Other_Farms_Local, Other_Farms_Local) + '%' and
Supplemental_Catagories LIKE '%' + ISNULL(@Supplemental_Catagories, Supplemental_Catagories) + '%' and
Begin_Operation = @Begin_Operation and
Staffed LIKE '%' + ISNULL(@Staffed, Staffed) + '%' and
Liability_Insurance = @Liability_Insurance and
Customers_Peak_Season = @Customers_Peak_Season and
Customers_2015 = @Customers_2015 and
Customers_2014 = @Customers_2014 and
Percent_Self_Produced LIKE '%' + ISNULL(@Percent_Self_Produced, Percent_Self_Produced) + '%' and
EBT = @EBT
END

StackTrace堆栈跟踪

[SqlException (0x80131904): Procedure or function 'SearchFarmStand' expects parameter '@Farm_Business_Name', which was not supplied.]
System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction) +2434922
System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction) +5736592
System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose) +285
System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady) +3731
System.Data.SqlClient.SqlDataReader.TryConsumeMetaData() +58
System.Data.SqlClient.SqlDataReader.get_MetaData() +89
System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString) +379
System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async, Int32 timeout, Task& task, Boolean asyncWrite, SqlDataReader ds, Boolean describeParameterEncryptionRequest) +2026
System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, TaskCompletionSource`1 completion, Int32 timeout, Task& task, Boolean asyncWrite) +375
System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method) +53
System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method) +240
System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior behavior) +41
System.Data.Common.DbCommand.System.Data.IDbCommand.ExecuteReader(CommandBehavior behavior) +12
System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) +139
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior) +136
System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, String srcTable) +86
System.Web.UI.WebControls.SqlDataSourceView.ExecuteSelect(DataSourceSelectArguments arguments) +1494
System.Web.UI.WebControls.BaseDataList.GetData() +58
System.Web.UI.WebControls.DataList.CreateControlHierarchy(Boolean useDataSource) +294
System.Web.UI.WebControls.BaseDataList.OnDataBinding(EventArgs e) +64
System.Web.UI.WebControls.BaseDataList.DataBind() +81
System.Web.UI.WebControls.BaseDataList.EnsureDataBound() +62
System.Web.UI.WebControls.BaseDataList.CreateChildControls() +69
System.Web.UI.Control.EnsureChildControls() +92
System.Web.UI.Control.PreRenderRecursiveInternal() +42
System.Web.UI.Control.PreRenderRecursiveInternal() +160
System.Web.UI.Control.PreRenderRecursiveInternal() +160
System.Web.UI.Control.PreRenderRecursiveInternal() +160
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +883
<asp:CheckBox ID="VegetablesSearch" Text="Vegetables" runat="server"></asp:CheckBox><br />

If VegetablesSearch.Text = "True"

What makes you think the text of the CheckBox will be "True"?是什么让您认为 CheckBox 的文本将是“True”?

So I figured out what was happening.所以我弄清楚发生了什么。 I had an extra SQLDataSource that was set to pull the stored procedure, however there were no parameters being set within the sqldatasource.我有一个额外的 SQLDataSource 设置为提取存储过程,但是在 sqldatasource 中没有设置参数。 This was separate from the VB that I had created to create the parameters.这与我为创建参数而创建的 VB 是分开的。 What I've done is removed the needless sqldatasource and my code is now working perfectly.我所做的是删除了不必要的 sqldatasource,我的代码现在可以完美运行。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM