3

Environment:

  • Visual Studio 2010 (.NET FrameWork 4)

  • ASP.NET web Application

  • Oracle Database

  • using System.Data.OracleClient

    I have a web form where a user can enter any or no data into text boxes corresponding to each parameter in my query.if user entered no data the text box will get "0" value.

here is my query:

SELECT "CardNo" , "Name"
FROM CSC.CommercialCardList
WHERE("CardNo"=:CardNo or :CardNo=0) and ("Name"=:Name or :Name=0)

when I right click on the query from the tableadaptor in the MYDATABASE.xsd panel, and select 'Preview Data' and fill parameter values with "0" i get the error (" ORA-01008 : Not all variables bound" )

can anyone help me?

--EDIT--

CardNo = (CardNoTextBox.Text != String.Empty) ? CardNoTextBox.Text : "0";
Name = (NameTextBox.Text != String.Empty) ? NameTextBox.Text : "0";
CommercialCardList.Fill(dt, CardNo,Name);
ds.Tables.Add(dt);
Community
  • 1
  • 1
elh4m v
  • 123
  • 1
  • 13
  • Can you show your code? Not the SQL, but your VB/C#? – Hambone Dec 02 '15 at 12:51
  • CardNo = (CardNoTextBox.Text != String.Empty) ? CardNoTextBox.Text : "0"; Name = (NameTextBox.Text != String.Empty) ? NameTextBox.Text : "0"; CommercialCardList.Fill(dt, CardNo,Name); ds.Tables.Add(dt); – elh4m v Dec 03 '15 at 14:39
  • Can you also add the code where you actually talk to the Oracle server? It should have an `OracleCommand` object... – Hambone Dec 03 '15 at 14:56

2 Answers2

1

You need to bind 4 variables as part of your code.

2 for "CardNo"=:CardNo or :CardNo=0

2 for "Name"=:Name or :Name=0

Durga Viswanath Gadiraju
  • 3,896
  • 2
  • 14
  • 21
0

You have to set command BindByName As true :

1- In OracleCommand as the below

 OracleCommand cmd = new OracleCommand();

2- In Tableadaptor as the below and call the SetBindByName with ture value

namespace MyTableAdapters
{
    public partial class MyTabTableAdapter
    {
        public bool SetBindByName
        {
            set
            {
                this.Adapter.InsertCommand.BindByName = value;
                this.Adapter.UpdateCommand.BindByName = value;
                this.Adapter.DeleteCommand.BindByName = value;
                foreach (Oracle.DataAccess.Client.OracleCommand cmd in this.CommandCollection)
                {
                    cmd.BindByName = value;
                }
            }
        }
    }
}
Osama AbuSitta
  • 3,918
  • 4
  • 35
  • 51