我在aspx.cs页面中收到错误 [英] iam getting an error in aspx.cs page

查看:87
本文介绍了我在aspx.cs页面中收到错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

protected void Button1_Click1(object sender,EventArgs e)

{

try

{

SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings [RegistrationConnectionString]。ConnectionString);

con.Open();

string insertQuery =insert into UserData(User Name,Email) ,密码,国家/地区)值(@ Uname,@ Email,@ Password,@ Country);

SqlCommand com = new SqlCommand(insertQuery,con);

com。 Parameters.AddWithValue(@ Uname,TextBoxUN.Text);

com.Parameters.AddWithValue(@ email,TextBoxEmail.Text);

com.Parameters。 AddWithValue(@ password,TextBoxPass.Text);

com.Parameters.AddWithValue(@ country,DropDownListCountry.SelectedItem.ToString());



com.ExecuteNonQuery();

Response.Redirect(Mnager.aspx);

Response.Write(注册成功..........);



con.Close();

}

catch(exception ex)

{

Response.Write(Error:+ ex.ToString());

}

protected void Button1_Click1(object sender, EventArgs e)
{
try
{
SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["RegistrationConnectionString"].ConnectionString);
con.Open();
string insertQuery = "insert into UserData(User Name,Email,Password,Country)values(@Uname,@Email,@Password,@Country)";
SqlCommand com = new SqlCommand(insertQuery, con);
com.Parameters.AddWithValue("@Uname", TextBoxUN.Text);
com.Parameters.AddWithValue("@email", TextBoxEmail.Text);
com.Parameters.AddWithValue("@password", TextBoxPass.Text);
com.Parameters.AddWithValue("@country", DropDownListCountry.SelectedItem.ToString());

com.ExecuteNonQuery();
Response.Redirect("Mnager.aspx");
Response.Write("Registration is Successfull..........");

con.Close();
}
catch (Exception ex)
{
Response.Write("Error:" + ex.ToString());
}

推荐答案

使用以下代码..



Use the below code..

protected void Button1_Click1(object sender, EventArgs e)
        {
            try
            {
                SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["RegistrationConnectionString"].ConnectionString);
                con.Open();
                string insertQuery = "insert into UserData([User Name],Email,Password,Country)values(@Uname,@Email,@Password,@Country)";
                SqlCommand com = new SqlCommand(insertQuery, con);
                com.Parameters.AddWithValue("@Uname", TextBoxUN.Text);
                com.Parameters.AddWithValue("@email", TextBoxEmail.Text);
                com.Parameters.AddWithValue("@password", TextBoxPass.Text);
                com.Parameters.AddWithValue("@country", DropDownListCountry.SelectedItem.ToString());

                com.ExecuteNonQuery();
                Response.Redirect("Mnager.aspx");
                Response.Write("Registration is Successfull..........");

               
            }
            catch (Exception ex)
            {
                Response.Write("Error:" + ex.ToString());
            }
            finally
            {
                con.Close();
            }
        }


检查上一个问题的答案,它是相同的解决方案。



我在defaul.aspx中收到错误.cs页面 [ ^ ]
Check the answer to your previous question , its the same solution .

iam getting error in defaul.aspx.cs page[^]


这篇关于我在aspx.cs页面中收到错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆