SQL存储过程未收到从VB

时间:2016-03-25 18:04:24

标签: mysql asp.net vb.net stored-procedures visual-studio-2015

所以我已经与我一直在努力的项目达成了帷幕。我试图通过让用户在每个表单字段中输入数据来获取搜索表单,然后搜索所有特定字段。这应该返回所有适用的行。

当用户运行搜索时,发生的事情是从表单字段中获取文本,并将其带入VB进行验证,然后将其推送到存储过程中。但是,存储过程没有看到正在传递的参数。我尝试了一些尝试获取数据的不同方法,但它并没有发生。当我使用断点运行代码时,我可以看到文本被带入VB中就好了,但它没有作为参数传递(事实上,我在断点窗口中找不到任何东西)说我的参数正在生成)

我收到的错误是:

程序或功能' SearchFarmStand'需要参数' @ Farm_Business_Name',这是未提供的。

我已经尝试谷歌搜索几个小时来解决这个问题但没有成功

我做了很多编辑,希望能让它发挥作用,但我没有成功。我已经尝试将参数的默认值设置为NULL,但仍然没有获取参数,虽然它确实通过了该过程,但它只返回任何内容。在VB方面,我还尝试了许多不同的方法来使用cmd.Parameter.Add和cmd.Parameter.AddWithValue声明参数。我的代码显示了我最近获取参数的尝试。

任何帮助都会很棒,因为我完全陷入困境

以下是我的代码:

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>

下面的另一个面板用于显示我的数据,以及另一个用于存储返回的搜索数据的数据列表。

背后代码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

存储过程SearchFarmStand.sql UPDATED

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

栈跟踪

[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

2 个答案:

答案 0 :(得分:0)

<asp:CheckBox ID="VegetablesSearch" Text="Vegetables" runat="server"></asp:CheckBox><br />

If VegetablesSearch.Text = "True"

是什么让你认为CheckBox的文字是“真的”?

答案 1 :(得分:0)

所以我弄清楚发生了什么。我有一个额外的SQLDataSource被设置为拉取存储过程,但是sqldatasource中没有设置任何参数。这与我创建的用于创建参数的VB是分开的。我所做的就是删除了不必要的sqldatasource,我的代码现在运行得很好。