ORA-01008:并非所有变量都绑定 - ASP.net Web 应用程序



当我尝试使用 GridView 页脚模板将数据插入 Oracle 数据库以将数据插入 Oracle 数据库时,我在插入查询中收到此"ORA-01008:并非所有变量都绑定"错误将数据插入 oracle 数据库,我在服务器上测试了查询,它工作正常,但是当我尝试运行应用程序并使用添加按钮执行查询时,它会显示错误

**网格视图

代码正在使用模板字段,因此我可以编辑网格视图页脚模板**

<asp:GridView ID="gvmb"  runat="server" AutoGenerateColumns="False"  BackColor="#DEBA84"  BorderColor="#DEBA84" BorderStyle="None" BorderWidth="1px" CellPadding="3" CellSpacing="2" Width="60%" style="margin-left: 350px" Height="226px" ShowFooter="True" OnRowCommand="gvmb_RowCommand" DataKeyNames="member_id" ShowHeaderWhenEmpty="True">
                <FooterStyle BackColor="#F7DFB5" ForeColor="#8C4510" />
                <HeaderStyle BackColor="#A55129" Font-Bold="True" ForeColor="White" />
                <PagerStyle ForeColor="#8C4510" HorizontalAlign="Center" />
                <RowStyle BackColor="#FFF7E7" ForeColor="#8C4510" />
                <SelectedRowStyle BackColor="#738A9C" Font-Bold="True" ForeColor="White" />
                <SortedAscendingCellStyle BackColor="#FFF1D4" />
                <SortedAscendingHeaderStyle BackColor="#B95C30" />
                <SortedDescendingCellStyle BackColor="#F1E5CE" />
                <SortedDescendingHeaderStyle BackColor="#93451F" />
                <Columns>
                    <asp:TemplateField HeaderText="id">
                        <ItemTemplate>
                            <asp:Label text='<%# Eval("member_id") %>' runat="server"></asp:Label>
                        </ItemTemplate>
                        <EditItemTemplate>
                            <asp:TextBox ID="member" text='<%# Eval("member_id") %>' runat="server">
                            </asp:TextBox>
                        </EditItemTemplate>
                        <FooterTemplate>
                                     <asp:TextBox ID="member_idfooter"  runat="server">
                            </asp:TextBox>
                        </FooterTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="Name">
                        <ItemTemplate>
                            <asp:Label text='<%# Eval("user_name") %>' runat="server"></asp:Label>
                        </ItemTemplate>
                        <EditItemTemplate>
                            <asp:TextBox ID="uname" text='<%# Eval("user_name") %>' runat="server">
                            </asp:TextBox>
                        </EditItemTemplate>
                         <FooterTemplate>
                                     <asp:TextBox ID="user_namefooter" runat="server">
                            </asp:TextBox>
                        </FooterTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="address">
                        <ItemTemplate>
                            <asp:Label text='<%# Eval("address") %>' runat="server"></asp:Label>
                        </ItemTemplate>
                        <EditItemTemplate>
                            <asp:TextBox ID="addres" text='<%# Eval("address") %>' runat="server">
                            </asp:TextBox>
                        </EditItemTemplate>
                         <FooterTemplate>
                                     <asp:TextBox ID="addressfooter" runat="server">
                            </asp:TextBox>
                        </FooterTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="Email">
                        <ItemTemplate>
                            <asp:Label text='<%# Eval("email_address") %>' runat="server"></asp:Label>
                        </ItemTemplate>
                        <EditItemTemplate>
                            <asp:TextBox ID="email" text='<%# Eval("email_address") %>' runat="server">
                            </asp:TextBox>
                        </EditItemTemplate>
                         <FooterTemplate>
                                     <asp:TextBox ID="email_addressfooter" runat="server">
                            </asp:TextBox>
                        </FooterTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="password">
                        <ItemTemplate>
                            <asp:Label text='<%# Eval("password") %>' runat="server"></asp:Label>
                        </ItemTemplate>
                        <EditItemTemplate>
                            <asp:TextBox ID="pass" text='<%# Eval("password") %>' runat="server">
                            </asp:TextBox>
                        </EditItemTemplate>
                         <FooterTemplate>
                                     <asp:TextBox ID="passwordfooter" runat="server">
                            </asp:TextBox>
                        </FooterTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="mobile number">
                        <ItemTemplate>
                            <asp:Label text='<%# Eval("mob_number") %>' runat="server"></asp:Label>
                        </ItemTemplate>
                        <EditItemTemplate>
                            <asp:TextBox ID="mob" text='<%# Eval("mob_number") %>' runat="server">
                            </asp:TextBox>
                        </EditItemTemplate>
                         <FooterTemplate>
                                     <asp:TextBox ID="mob_numberfooter" runat="server">
                            </asp:TextBox>
                        </FooterTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField>
                        <ItemTemplate>
                            <asp:LinkButton ID="edit" runat="server" CommandName="edit" ToolTip="Edit">Edit</asp:LinkButton>
                              <asp:LinkButton ID="delete" runat="server" CommandName="delete" ToolTip="Delete">Delete</asp:LinkButton>
                        </ItemTemplate> 
                        <FooterTemplate>
                             <asp:LinkButton ID="add" runat="server" CommandName="add" ToolTip="add">add</asp:LinkButton>
                        </FooterTemplate>
                    </asp:TemplateField>
                </Columns>
            </asp:GridView>
            <br />
            <asp:Label Text="" ID="lblsuccess" runat="server" ForeColor="Green"></asp:Label>
            <br />
            <asp:Label Text="" ID="lblerror" runat="server" ForeColor="red"></asp:Label>
    </div>

C# 代码,包括插入事件,我在添加中收到错误。ExcuteNonQuery(( 方法

 if (e.CommandName.Equals("add"))
            {
                coon.Open();
                string query = "INSERT INTO members (member_id, user_name,address ,mob_number,email_address,password ) VALUES (:member_id, :user_name,:address ,:mob_number,:email_address,:password)";
                OleDbCommand add = new OleDbCommand(query, coon);
                add.Parameters.AddWithValue(":member_id", (gvmb.FooterRow.FindControl("member_idfooter") as TextBox).Text.Trim());
                add.Parameters.AddWithValue(":user_name", (gvmb.FooterRow.FindControl("user_namefooter") as TextBox).Text.Trim());
                add.Parameters.AddWithValue(":address", (gvmb.FooterRow.FindControl("addressfooter") as TextBox).Text.Trim());
                add.Parameters.AddWithValue(":mob_number", (gvmb.FooterRow.FindControl("mob_numberfooter") as TextBox).Text.Trim());
                add.Parameters.AddWithValue(":email_address", (gvmb.FooterRow.FindControl("email_addressfooter") as TextBox).Text.Trim());
                add.Parameters.AddWithValue(":password", (gvmb.FooterRow.FindControl("passwordfooter") as TextBox).Text.Trim());
                add.ExecuteNonQuery();
                fillmembers();
                lblsuccess.Text = "New Recored Added";
                lblerror.Text = "";
                coon.Close();
            }

如果可以切换到使用 OracleCommand 代替,则可以使用 Oracle 特有的 OracleParamater 来实现此功能。

cmd.Parameters.Add(new OracleParameter("client", client));

根据您拥有的命名空间(Oracle.DataAccess.Client 或 System.Data.OracleClient(,您可以使用 AddWithValue 版本。

已解决 我刚刚将查询中的 : 参数更改为 ? 它有效,我想参数序列有问题

插入成员 (member_id、user_name、地址、mob_number、email_address、密码( 值 (?, ?,?,?,?,?(

相关内容

  • 没有找到相关文章

最新更新