Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

sqlcommand issue

Posted on 2012-09-21
2
Medium Priority
?
669 Views
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 = 

ConfigurationManager.ConnectionStrings["upscale"].ConnectionString;
        conn.Open();

        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"?>
<configuration>
  <connectionStrings>
    <add name="upscale" connectionString="Data Source=db.043290481.hostsource.net;database=upscale;uid=xxxxxxx;password=xxxxxx;"/>    
  </connectionStrings>
  <system.web>
    <authentication mode="Forms" />
    <customErrors mode="Off" />
    <compilation debug="true" targetFramework="4.0"/>
  </system.web>
</configuration>

Open in new window

Thanks!
0
Comment
Question by:Isaac
2 Comments
 
LVL 75

Accepted Solution

by:
käµfm³d   👽 earned 2000 total points
ID: 38423686
In that line, change "sb" to "sb.ToString()".
0
 
LVL 5

Author Closing Comment

by:Isaac
ID: 38423687
Excellent...Thanks!
0

Featured Post

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
High user turnover can cause old/redundant user data to consume valuable space. UserResourceCleanup was developed to address this by automatically deleting user folders when the user account is deleted.
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Enter Foreign and Special Characters Enter characters you can't find on a keyboard using its ASCII code ... and learn how to make a handy reference for yourself using Excel ~ Use these codes in any Windows application! ... whether it is a Micr…
Suggested Courses
Course of the Month14 days, 21 hours left to enroll

577 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