Link to home
Start Free TrialLog in
Avatar of zimmer9
zimmer9Flag for United States of America

asked on

How do I resolve the error "The type or namespace name 'SQLConnection' could not be found (are you missing a using directive or an assembly reference?)"?

How do I resolve the following errors in my code that follows:

I am using VS2010 and working on a C# Web application.

Error      1      The type or namespace name 'SQLConnection' could not be found (are you missing a using directive or an assembly reference?)      \\msad\root\na\ny\users\zimmermj\visual studio 2010\Projects\SMRWebForm\SMRWebForm\SMRWebForm1.aspx.cs      64      20      SMRWebForm
Error      8      The type or namespace name 'SQLCommand' could not be found (are you missing a using directive or an assembly reference?)      \\msad\root\na\ny\users\zimmermj\visual studio 2010\Projects\SMRWebForm\SMRWebForm\SMRWebForm1.aspx.cs      74      24      SMRWebForm

------------------------------------

using System;
using System.Data;
using System.Data.SqlClient;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO;
using System.Text;
using System.Text.RegularExpressions;

namespace SMRWebForm
{
    public partial class SMRWebForm1 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {                        
            using (SQLConnection conn = new SQLConnection(connString))
            {
                conn.Open();
                StringBuilder sb = new StringBuilder();
                string[] sArray = new string[9];
                sArray[0] = banknum;
                sArray[1] = transDtYR;
                sArray[2] = transDtMnth;
                sb.AppendFormat( myInsert, sArray);
                string cmdText = sb.ToString();
                using (SQLCommand cmd = new SQLCommand(conn, cmdText))
                {
                   int rowsAffected = cmd.ExecuteNonQuery();
                }
            }
        }
    }
}
ASKER CERTIFIED SOLUTION
Avatar of Meir Rivkin
Meir Rivkin
Flag of Israel image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial