超级紧急
时间:2011-12-05
来源:互联网
             我的注册代码
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.Page;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
string sqlconnstr = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
SqlConnection sqlconn = new SqlConnection(sqlconnstr);
SqlCommand sqlcommand = new SqlCommand();
sqlcommand.Connection = sqlconn;
sqlcommand.CommandText = "insert into customer(customerID,Name,Password,Address,Phone,Email) values(@customerID,@Name,@Password,@Address,@Phone,@Email)";
sqlcommand.Parameters.AddWithValue("@customerID", ID.Text);
sqlcommand.Parameters.AddWithValue("@Name", name.Text);
sqlcommand.Parameters.AddWithValue("@Password", password.Text);
sqlcommand.Parameters.AddWithValue("@Address", address.Text);
sqlcommand.Parameters.AddWithValue("@phone", phone.Text);
sqlcommand.Parameters.AddWithValue("@Email", email.Text);
try
{
sqlconn.Open();
sqlcommand.ExecuteNonQuery();
}
catch (Exception ex)
{
Label1.Text = "" + ex.Message;
}
finally
{
sqlcommand = null;
sqlconn.Close();
sqlconn = null;
}
}
}
但是有错误,错误提示是
错误 1 “string”不包含“Text”的定义,并且找不到可接受类型为“string”的第一个参数的扩展方法“Text”(是否缺少 using 指令或程序集引用?) C:\Users\pig\Documents\Visual Studio 2010\WebSites\WebSite1\Default.aspx.cs 28 62 C:\...\WebSite1\
            
            using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.Page;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
string sqlconnstr = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
SqlConnection sqlconn = new SqlConnection(sqlconnstr);
SqlCommand sqlcommand = new SqlCommand();
sqlcommand.Connection = sqlconn;
sqlcommand.CommandText = "insert into customer(customerID,Name,Password,Address,Phone,Email) values(@customerID,@Name,@Password,@Address,@Phone,@Email)";
sqlcommand.Parameters.AddWithValue("@customerID", ID.Text);
sqlcommand.Parameters.AddWithValue("@Name", name.Text);
sqlcommand.Parameters.AddWithValue("@Password", password.Text);
sqlcommand.Parameters.AddWithValue("@Address", address.Text);
sqlcommand.Parameters.AddWithValue("@phone", phone.Text);
sqlcommand.Parameters.AddWithValue("@Email", email.Text);
try
{
sqlconn.Open();
sqlcommand.ExecuteNonQuery();
}
catch (Exception ex)
{
Label1.Text = "" + ex.Message;
}
finally
{
sqlcommand = null;
sqlconn.Close();
sqlconn = null;
}
}
}
但是有错误,错误提示是
错误 1 “string”不包含“Text”的定义,并且找不到可接受类型为“string”的第一个参数的扩展方法“Text”(是否缺少 using 指令或程序集引用?) C:\Users\pig\Documents\Visual Studio 2010\WebSites\WebSite1\Default.aspx.cs 28 62 C:\...\WebSite1\
作者: LYE1219 发布时间: 2011-12-05
             using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.Page;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
string sqlconnstr = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
SqlConnection sqlconn = new SqlConnection(sqlconnstr);
SqlCommand sqlcommand = new SqlCommand();
sqlcommand.Connection = sqlconn;
sqlcommand.CommandText = "insert into customer(customerID,Name,Password,Address,Phone,Email) values(@customerID,@Name,@Password,@Address,@Phone,@Email)";
sqlcommand.Parameters.AddWithValue("@customerID", ID.Text);
sqlcommand.Parameters.AddWithValue("@Name", name.Text);
sqlcommand.Parameters.AddWithValue("@Password", password.Text);
sqlcommand.Parameters.AddWithValue("@Address", address.Text);
sqlcommand.Parameters.AddWithValue("@phone", phone.Text);
sqlcommand.Parameters.AddWithValue("@Email", email.Text);
try
{
sqlconn.Open();
sqlcommand.ExecuteNonQuery();
}
catch (Exception ex)
{
Label1.Text = "" + ex.Message;
}
finally
{
sqlcommand = null;
sqlconn.Close();
sqlconn = null;
}
}
}
看红色标记部分,怎么控件的ID名称起了了叫ID的,换个名字customerID
            using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.Page;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
string sqlconnstr = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
SqlConnection sqlconn = new SqlConnection(sqlconnstr);
SqlCommand sqlcommand = new SqlCommand();
sqlcommand.Connection = sqlconn;
sqlcommand.CommandText = "insert into customer(customerID,Name,Password,Address,Phone,Email) values(@customerID,@Name,@Password,@Address,@Phone,@Email)";
sqlcommand.Parameters.AddWithValue("@customerID", ID.Text);
sqlcommand.Parameters.AddWithValue("@Name", name.Text);
sqlcommand.Parameters.AddWithValue("@Password", password.Text);
sqlcommand.Parameters.AddWithValue("@Address", address.Text);
sqlcommand.Parameters.AddWithValue("@phone", phone.Text);
sqlcommand.Parameters.AddWithValue("@Email", email.Text);
try
{
sqlconn.Open();
sqlcommand.ExecuteNonQuery();
}
catch (Exception ex)
{
Label1.Text = "" + ex.Message;
}
finally
{
sqlcommand = null;
sqlconn.Close();
sqlconn = null;
}
}
}
看红色标记部分,怎么控件的ID名称起了了叫ID的,换个名字customerID
作者: taomanman 发布时间: 2011-12-05
             还有参数注意大小写一致,看下面红色标记部分。
sqlcommand.CommandText = "insert into customer(customerID,Name,Password,Address,Phone,Email) values(@customerID,@Name,@Password,@Address,@Phone,@Email)";
sqlcommand.Parameters.AddWithValue("@customerID", ID.Text);
sqlcommand.Parameters.AddWithValue("@Name", name.Text);
sqlcommand.Parameters.AddWithValue("@Password", password.Text);
sqlcommand.Parameters.AddWithValue("@Address", address.Text);
sqlcommand.Parameters.AddWithValue("@phone", phone.Text);
sqlcommand.Parameters.AddWithValue("@Email", email.Text);
            sqlcommand.CommandText = "insert into customer(customerID,Name,Password,Address,Phone,Email) values(@customerID,@Name,@Password,@Address,@Phone,@Email)";
sqlcommand.Parameters.AddWithValue("@customerID", ID.Text);
sqlcommand.Parameters.AddWithValue("@Name", name.Text);
sqlcommand.Parameters.AddWithValue("@Password", password.Text);
sqlcommand.Parameters.AddWithValue("@Address", address.Text);
sqlcommand.Parameters.AddWithValue("@phone", phone.Text);
sqlcommand.Parameters.AddWithValue("@Email", email.Text);
作者: taomanman 发布时间: 2011-12-05
             sqlcommand.Parameters.AddWithValue("@customerID", ID.Text);
sqlcommand.Parameters.AddWithValue("@Name", name.Text);
sqlcommand.Parameters.AddWithValue("@Password", password.Text);
sqlcommand.Parameters.AddWithValue("@Address", address.Text);
sqlcommand.Parameters.AddWithValue("@phone", phone.Text);
sqlcommand.Parameters.AddWithValue("@Email", email.Text);
ID、name那些什么?在哪里定义的?
            sqlcommand.Parameters.AddWithValue("@Name", name.Text);
sqlcommand.Parameters.AddWithValue("@Password", password.Text);
sqlcommand.Parameters.AddWithValue("@Address", address.Text);
sqlcommand.Parameters.AddWithValue("@phone", phone.Text);
sqlcommand.Parameters.AddWithValue("@Email", email.Text);
ID、name那些什么?在哪里定义的?
作者: dongxinxi 发布时间: 2011-12-05
 相关阅读 更多  
      
    热门阅读
-   office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具 office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具阅读:74 
-   如何安装mysql8.0 如何安装mysql8.0阅读:31 
-   Word快速设置标题样式步骤详解 Word快速设置标题样式步骤详解阅读:28 
-   20+道必知必会的Vue面试题(附答案解析) 20+道必知必会的Vue面试题(附答案解析)阅读:37 
-   HTML如何制作表单 HTML如何制作表单阅读:22 
-   百词斩可以改天数吗?当然可以,4个步骤轻松修改天数! 百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!阅读:31 
-   ET文件格式和XLS格式文件之间如何转化? ET文件格式和XLS格式文件之间如何转化?阅读:24 
-   react和vue的区别及优缺点是什么 react和vue的区别及优缺点是什么阅读:121 
-   支付宝人脸识别如何关闭? 支付宝人脸识别如何关闭?阅读:21 
-   腾讯微云怎么修改照片或视频备份路径? 腾讯微云怎么修改照片或视频备份路径?阅读:28 















