compiler error c# CS0103: The name 'CommandType' does not exist in the current conte

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • pratheek
    New Member
    • Feb 2013
    • 1

    compiler error c# CS0103: The name 'CommandType' does not exist in the current conte

    Code:
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Data.SqlClient;
    using System.Web.Security;
    using System.Data;
    
    public partial class Login : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
    
        }
        protected void Button1_Click(object sender, EventArgs e)
        {
    
            SqlConnection Cn = new SqlConnection("server=nikhil;database=mydb;uid=sa;pwd=123");
            SqlCommand Cmd = new SqlCommand();
            Cmd.Connection = Cn;
            Cmd.CommandText = "validateuser";
            Cn.Open();
            Cmd.CommandType =CommandType.StoredProcedure;
            Cmd.Parameters.Clear();
            Cmd.Parameters.AddWithValue("", TextBox1.Text);
            Cmd.Parameters.AddWithValue("", TextBox2.Text);
            SqlDataReader Dr = Cmd.ExecuteReader();
            if (Dr.Read())
                FormsAuthentication.RedirectFromLoginPage(TextBox1.Text, false);
            else
                Label1.Text = "user id/password is wrong";
    
            Dr.Close();
            Cn.Close();
        }
    }
    Last edited by Meetee; Feb 20 '13, 11:45 AM. Reason: Use code tags [/CODE] around code
Working...