Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7608553
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T00:56:33+00:00 2026-05-31T00:56:33+00:00

Whenever I submit my form, it gives me an error code: invalid column name

  • 0

Whenever I submit my form, it gives me an error code:

“invalid column name” for all of the eventspecialist, phone, phon2, etc. and @SPECIALIST, @CUST_PHONE, @CUST_PHONE2, etc.

Here is my code below, perhaps I’m not writing the SQL statement or parameters correctly? The ones with @ infront are what’s in my database, and the other lowercase ones are my textboxes. I’m relatively new to this type of coding.

Edit: Changed my INSERT INTO statement to what was suggested. The error still persists, but is only minimized to

“Invalid column name eventspecialist, Invalid column name phone, Invalid column name phone2, etc.”

private void execution(string eventspecialist, string phone, string phone2, string firstname, string lastname, string besttime, string companyname, string nonprofit, string requesteddate, string requestedtime, string attendance, string eventtype, string other, string leadsource, string notes, string catering, string bar, string damagedeposit, string dancefloor, string griddate, string gridnotes, string comments)
{
    SqlConnection conn = new SqlConnection(GetConnectionString());

    string sql = "INSERT INTO tblcontacts (@SPECIALIST, @CUST_PHONE1, @CUST_PHONE2, @CUST_FNAME, @CUST_LNAME, @BEST_TIME, @COMPANY_NAME, @NONPROFIT, @REQ_DATE, @REQ_TIME, @ATTENDANCE, @EVENT_TYPE, @OTHER_DESC, @LEAD_SOURCE, @NOTES, @CATERING, @BAR, @DAMAGE_DEPOSIT, @DANCE_FLOOR) VALUES (eventspecialist, phone, phone2, firstname, lastname, besttime, companyname, nonprofit, requesteddate, requestedtime, attendance, eventtype, other, leadsource, notes, catering, bar, damagedeposit, dancefloor)";
    string sql2 = "INSERT INTO tblnotes (@NOTEDATE, @NOTEBY, @COMMENTS) VALUES (griddate, gridnotes, comments)";

    try
    {
        conn.Open();
        SqlCommand cmd = new SqlCommand(sql, conn);

        cmd.Parameters.Add("@SPECIALIST", SqlDbType.NVarChar, 50).Value = eventspecialist;
        cmd.Parameters.Add("@CUST_PHONE1", SqlDbType.NVarChar, 50).Value = phone;
        cmd.Parameters.Add("@CUST_PHONE2", SqlDbType.NVarChar, 50).Value = phone2;
        cmd.Parameters.Add("@CUST_FNAME", SqlDbType.NVarChar, 50).Value = firstname;
        cmd.Parameters.Add("@CUST_LNAME", SqlDbType.NVarChar, 50).Value = lastname;
        cmd.Parameters.Add("@BEST_TIME", SqlDbType.NVarChar, 50).Value = besttime;
        cmd.Parameters.Add("@COMPANY_NAME", SqlDbType.NVarChar, 225).Value = companyname;
        cmd.Parameters.Add("@NONPROFIT", SqlDbType.NVarChar, 10).Value = nonprofit;
        cmd.Parameters.Add("@REQ_DATE", SqlDbType.Date, 20).Value = requesteddate;
        cmd.Parameters.Add("@REQ_TIME", SqlDbType.Time, 20).Value = requestedtime;
        cmd.Parameters.Add("@ATTENDANCE", SqlDbType.Int, 50).Value = attendance;
        cmd.Parameters.Add("@EVENT_TYPE", SqlDbType.NVarChar, 50).Value = eventtype;
        cmd.Parameters.Add("@OTHER_DESC", SqlDbType.NVarChar, 225).Value = other;
        cmd.Parameters.Add("@LEAD_SOURCE", SqlDbType.NVarChar, 50).Value = leadsource;
        cmd.Parameters.Add("@NOTES", SqlDbType.NVarChar, 225).Value = notes;
        cmd.Parameters.Add("@CATERING", SqlDbType.NVarChar, 1).Value = catering;
        cmd.Parameters.Add("@BAR", SqlDbType.NVarChar, 1).Value = bar;
        cmd.Parameters.Add("@DAMAGE_DEPOSIT", SqlDbType.NVarChar, 19).Value = damagedeposit;
        cmd.Parameters.Add("@DANCE_FLOOR", SqlDbType.Money).Value = Decimal.Parse(dancefloor);


        cmd.CommandType = CommandType.Text;
        cmd.ExecuteNonQuery();
    }
    catch (System.Data.SqlClient.SqlException ex_msg)
    {
        string msg = "Error occured while inserting";
        msg += ex_msg.Message;
        throw new Exception(msg);
    }
    finally
    {

        conn.Close();
    }
    try
    {
        conn.Open();
        SqlCommand cmd = new SqlCommand(sql2, conn);

        cmd.Parameters.Add("@NOTEDATE", SqlDbType.Date, 50).Value = griddate;
        cmd.Parameters.Add("@NOTEBY", SqlDbType.NVarChar, 50).Value = gridnotes;
        cmd.Parameters.Add("@COMMENTS", SqlDbType.NVarChar, 50).Value = comments;

        cmd.CommandType = CommandType.Text;
        cmd.ExecuteNonQuery();
    }
    catch (System.Data.SqlClient.SqlException ex_msg)
    {
        string msg = "Error occured while inserting";
        msg += ex_msg.Message;
        throw new Exception(msg);
    }
    finally
    {

        conn.Close();
    }

}
protected void Page_Load(object sender, EventArgs e)
{
    griddate.Text = DateTime.Now.ToString("yyyy/MM/dd");
}
protected void submit_Click(object sender, EventArgs e)
{
    if (requesteddate.Text == "")
    {
        Finish.Text = "Please complete the form!";
    }
    else if (requestedtime.Text == "")
    {
        Finish.Text = "Please complete the form!";
    }
    else if (attendance.Text == "")
    {
        Finish.Text = "Please complete the form!";
    }
    else
    {
        execution(eventspecialist.Text, phone.Text, phone2.Text, firstname.Text, lastname.Text, besttime.SelectedItem.Text, companyname.Text, nonprofit.Text, requesteddate.Text, requestedtime.Text, attendance.Text, eventtype.SelectedItem.Text, other.Text, leadsource.SelectedItem.Text, notes.Text, catering.Text, bar.Text, damagedeposit.Text, dancefloor.SelectedItem.Text, griddate.Text, gridnotes.SelectedItem.Text, comments.Text);
        Finish.Visible = false;
        conform.Visible = true;
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T00:56:35+00:00Added an answer on May 31, 2026 at 12:56 am

    I suppose that your columns are

    SPECIALIST, CUST_PHONE1, CUST_PHONE2, CUST_FNAME, CUST_LNAME, BEST_TIME, 
    COMPANY_NAME, NONPROFIT, REQ_DATE, REQ_TIME, ATTENDANCE, EVENT_TYPE, OTHER_DESC, 
    LEAD_SOURCE, NOTES, CATERING, BAR, DAMAGE_DEPOSIT, DANCE_FLOOR
    

    if so you should change your INSERT INTO in this way

    INSERT INTO tblcontacts 
    (SPECIALIST, CUST_PHONE1, CUST_PHONE2, CUST_FNAME, CUST_LNAME, BEST_TIME, 
    COMPANY_NAME, NONPROFIT, REQ_DATE, REQ_TIME, ATTENDANCE, EVENT_TYPE, OTHER_DESC, LEAD_SOURCE, 
    NOTES, CATERING, BAR, DAMAGE_DEPOSIT, DANCE_FLOOR)
    VALUES
    (@SPECIALIST, @CUST_PHONE1, @CUST_PHONE2, @CUST_FNAME, @CUST_LNAME, @BEST_TIME, @COMPANY_NAME, 
     @NONPROFIT, @REQ_DATE, @REQ_TIME, @ATTENDANCE, @EVENT_TYPE, @OTHER_DESC, @LEAD_SOURCE, @NOTES, 
     @CATERING, @BAR, @DAMAGE_DEPOSIT, @DANCE_FLOOR)
    

    In your execution method you are creating parameters, but, then, in the insert statement
    first put the real column names and then, in the value part, the parameters names
    (with @prefix)

    As a side note, next time, try to format better your code.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I get this error whenever I submit the form also the action method is
I have set the enctype to: multipart/form-data yet whenever I submit this form, the
The very basic issue all developers face: Whenever user submits the form, the password
I'm having this problem with a form, whenever I submit a form in this
I want to submit a form whenever checkboxes are clicked (I already have ajax
I have code that gets called whenever the form is submitted, this then validates
Whenever I hit submit for paypal or credit card on this form, it always
In jQuery, if I assign class=auto_submit_form to a form, it will be submitted whenever
Whenever I run any jython program in Eclipse, I got the following error in
So I want to enable a submit button whenever an option in my select

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.