sqlcommand issue

Posted on 2012-09-21
Last Modified: 2012-09-21
I get a squiggly line under the bolded and underlined piece of code below.  Any ideas?

using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.Sql;
using System.Data.SqlClient;
using System.Web.Security;
using System.Web.Mail;
using System.Configuration;

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

    protected void Wizard1_FinishButtonClick(object sender, WizardNavigationEventArgs e)
SqlConnection conn = new SqlConnection();
        conn.ConnectionString = 


        System.Text.StringBuilder sb = new System.Text.StringBuilder(50);
        sb.Append("INSERT INTO tblConsigner(fname,lname,email,phone");
        sb.Append("VALUES(@fname, @lname, @email, @phone)");  

        [b][u]SqlCommand insert_cmd = new SqlCommand(sb, conn);[/u][/b]
        insert_cmd.Parameters.AddWithValue("@fname",  txtFname.Text.ToString());
        insert_cmd.Parameters.AddWithValue("@lname", txtLname.Text.ToString());
        insert_cmd.Parameters.AddWithValue("@email", txtEmail.Text.ToString());
        insert_cmd.Parameters.AddWithValue("@phone", txtPhone.Text.ToString());

Open in new window

Here's my web.config file.
<?xml version="1.0"?>
    <add name="upscale" connectionString="Data;database=upscale;uid=xxxxxxx;password=xxxxxx;"/>    
    <authentication mode="Forms" />
    <customErrors mode="Off" />
    <compilation debug="true" targetFramework="4.0"/>

Open in new window

Question by:Isaac
    LVL 74

    Accepted Solution

    In that line, change "sb" to "sb.ToString()".
    LVL 5

    Author Closing Comment


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Top 6 Sources for Identifying Threat Actor TTPs

    Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

    Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
    Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
    It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
    This video discusses moving either the default database or any database to a new volume.

    760 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    9 Experts available now in Live!

    Get 1:1 Help Now