Hi All.

I am currently at work on this program and have came accross this error when i debug the code in ASP via Internet Browser it displays the following message on top of the webform

"Command text was not set for the command object"

I am also having problems linking the data to a grid box via OleDbDataReader in a different form, could this be why i am getting this error? Basically i created a web form to accept data and once filled in it upadtes the database i have linked and then diplays the new form showing the upadated details in the web browser.

Please find below my code so far.

Sorry if i came off a bit confusing.


using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.OleDb;

namespace CW3
    public partial class AddCustomer : System.Web.UI.Page
        protected void Page_Load(object sender, EventArgs e)


        protected void Button1_Click(object sender, EventArgs e)
            OleDbConnection connect = new OleDbConnection();
            connect.ConnectionString = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=F:\Computer Forensics Year 2\Event Driven Programming\Re-Sit\SE2S02 CW3/Northwind.mdb;Persist Security Info=False;";

            OleDbCommand command = new OleDbCommand();
            command.Connection = connect;
            command.Parameters.AddWithValue("CustomerID", this.txtCustomerID.Text);
            command.Parameters.AddWithValue("CompanyName", this.txtCompanyName.Text);
            command.Parameters.AddWithValue("ContactName", this.txtContactName.Text);
            command.Parameters.AddWithValue("ContactTitle", this.txtContactTitle.Text);
            command.Parameters.AddWithValue("Address", this.txtAddress.Text);
            command.Parameters.AddWithValue("City", this.txtCity.Text);
            command.Parameters.AddWithValue("Region", this.txtRegion.Text);
            command.Parameters.AddWithValue("PostalCode", this.txtPostalCode.Text);
            command.Parameters.AddWithValue("Country", this.txtCountry.Text);
            command.Parameters.AddWithValue("Phone", this.txtPhone.Text);
            command.Parameters.AddWithValue("Fax", this.txtFax.Text);

            {   //May REMOVE
                OleDbDataReader reader = command.ExecuteReader();

                while (reader.Read() == true)

                int rowschanged = command.ExecuteNonQuery();
                if (rowschanged == 1)
                    txtCustomerID.Text = "";
                    txtCompanyName.Text = "";
                    txtContactName.Text = "";
                    txtContactTitle.Text = "";
                    txtAddress.Text = "";
                    txtCity.Text = "";
                    txtRegion.Text = "";
                    txtPostalCode.Text = "";
                    txtCountry.Text = "";
                    txtPhone.Text = "";
                    txtFax.Text = "";
                catch (Exception ex)

You are adding values, but what are you adding them to? There needs to be a SQL statement with as many placeholders as you have values to add, and it needs to come before you start adding values.

In other words, you have no command text, just like it told you.

This question has already been answered. Start a new discussion instead.