By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,952 Members | 1,617 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,952 IT Pros & Developers. It's quick & easy.

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

P: 1
Expand|Select|Wrap|Line Numbers
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Web;
  5. using System.Web.UI;
  6. using System.Web.UI.WebControls;
  7. using System.Data.SqlClient;
  8. using System.Web.Security;
  9. using System.Data;
  10.  
  11. public partial class Login : System.Web.UI.Page
  12. {
  13.     protected void Page_Load(object sender, EventArgs e)
  14.     {
  15.  
  16.     }
  17.     protected void Button1_Click(object sender, EventArgs e)
  18.     {
  19.  
  20.         SqlConnection Cn = new SqlConnection("server=nikhil;database=mydb;uid=sa;pwd=123");
  21.         SqlCommand Cmd = new SqlCommand();
  22.         Cmd.Connection = Cn;
  23.         Cmd.CommandText = "validateuser";
  24.         Cn.Open();
  25.         Cmd.CommandType =CommandType.StoredProcedure;
  26.         Cmd.Parameters.Clear();
  27.         Cmd.Parameters.AddWithValue("", TextBox1.Text);
  28.         Cmd.Parameters.AddWithValue("", TextBox2.Text);
  29.         SqlDataReader Dr = Cmd.ExecuteReader();
  30.         if (Dr.Read())
  31.             FormsAuthentication.RedirectFromLoginPage(TextBox1.Text, false);
  32.         else
  33.             Label1.Text = "user id/password is wrong";
  34.  
  35.         Dr.Close();
  36.         Cn.Close();
  37.     }
  38. }
Feb 20 '13 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.