嘿,伙计们仍在忙于我找到的注册表单文章,我按照伙计们的步骤插入了他发布的代码,但我似乎收到错误“在当前上下文中不存在”我做错了什么还是他的代码有问题?
http://www.c-sharpcorner.com/uploadfile/rohatash/simple-user-login-in-Asp-Net-using-C-Sharp/
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;
public partial class StudentLogin : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btnRegister_Click(object sender, EventArgs e)
{
string strcon = "Data Source=.;uid=sa;pwd=Password$2;database=master";
SqlConnection con = new SqlConnection(strcon);
SqlCommand com = new SqlCommand("VC-Temps", con);
com.CommandType = CommandType.StoredProcedure;
SqlParameter p1 = new SqlParameter("StudCode", TextBox3.Text);
SqlParameter p2 = new SqlParameter("Password", TextBox4.Text);
SqlParameter p3 = new SqlParameter("FirstName", TextBox5.Text);
SqlParameter p4 = new SqlParameter("LastName", TextBox6.Text);
SqlParameter p5 = new SqlParameter("Telephone", TextBox7.Text);
SqlParameter p6 = new SqlParameter("Course", TextBox8.Text);
SqlParameter p7 = new SqlParameter("Availability", DropDownList1.Text);
SqlParameter p8 = new SqlParameter("JobSkill", DropDownList2.Text);
SqlParameter p9 = new SqlParameter("Experience", DropDownList3.Text);
com.Parameters.Add(p1);
com.Parameters.Add(p2);
com.Parameters.Add(p3);
com.Parameters.Add(p4);
com.Parameters.Add(p5);
com.Parameters.Add(p6);
com.Parameters.Add(p7);
com.Parameters.Add(p8);
com.Parameters.Add(p9);
con.Open();
com.ExecuteNonQuery();
}
}
错误是:错误 3 当前上下文中不存在名称“CommandType” C:\Website\StudentLogin.aspx.cs 21 27 C:\Website\