错误1找不到类型或命名空间名称“连接”(您是否缺少using指令或程序集引用) [英] Error 1 The type or namespace name 'Connection' could not be found (are you missing a using directive or an assembly referene)

查看:187
本文介绍了错误1找不到类型或命名空间名称“连接”(您是否缺少using指令或程序集引用)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

using System;
using System.Web.Configuration;
using System.Configuration;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Security.Cryptography;
using System.Data.SqlClient;


namespace Enabling_Public_Auditability_and_Data_Dynamics
{
    public partial class Regestration : System.Web.UI.Page
    {
        //RSAParameters PublicKeyInfo;
        //RSAParameters PrivateKeyInfo;
        Connection cn = new Connection();
        SqlConnection con = new SqlConnection(WebConfigurationManager.ConnectionStrings["sri"].ToString());
        SqlCommand cmd;
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void btn_submit_Click(object sender, EventArgs e)
        {

          //  con = cn.conn();
            con.Open();
            cmd = new SqlCommand("INSERT INTO [Login]([User_ID],[Password],[username],[email],[gender],[DOB],[Qualification],[Designation],[ContactNo],[Address]) VALUES ('" + txt_userid.Text + "','" + txt_Password.Text + "','" + txt_Name.Text + "','" + txt_emailid.Text + "','" + rbl_Gender.SelectedValue + "','" + txt_DOB.Text + "','" + txt_qualification.Text + "','" + txt_Disignation.Text + "','" + txt_ContactNo.Text + "','" + txt_Address.Text + "')", con);


            if (cmd.ExecuteNonQuery() == 1)
            {
                Response.Write("<script>alert('Registration Successfully completed');</script>");
                Response.Redirect("~/login1.aspx");
                //Label2.Visible = true;
                //Button1.Visible = true;
            }
            else
                Response.Write("<script>alert('Registration failed');</script>");
            con.Close();
        }     
        protected void btn_close_Click(object sender, EventArgs e)
        {
            Session["user"] = "";
            Response.Redirect("~/login1.aspx");
        }

        protected void txt_userid_TextChanged(object sender, EventArgs e)
        {
            con = cn.conn();
            con.Open();
            cmd = new SqlCommand("select User_ID from login where User_ID='" + txt_userid.Text + "'", con);
            SqlDataReader rd = cmd.ExecuteReader();
            if (rd.Read())
            {
                if (rd[0].ToString() != "")
                {
                    Label1.Text = "user id not Availble";
                    txt_userid.Text = "";
                    txt_userid.Focus();
                }
                else
                {
                    Label1.Text = "User id Available";

                    txt_DOB.Focus();
                }
            }
            else
            {
                Label1.Text = "User id Available"; txt_DOB.Focus();
            }
            con.Close();
        }
    }
}

我想要正确的解决方案。

i want correct solution.

推荐答案

我们不能给你正确的解决方案,因为有太多的可能性。

但是...... 连接不是.NET类 - 它是一部分您的应用程序,如果它存在的话。鉴于你的其余代码,以及你在其中使用变量 cn 的地方,我建议你删除该行

We can't give you "correct solution" because there are far, far too many possibilities.
But...Connection is not a .NET class - it is part of your application, if it exists at all. Given the rest of your code, and where you use the variable cn in it, I would suggest that you remove the line
Connection cn = new Connection();

,也是实际使用它的唯一行:

completely, and also the only line where you actually use it:

con = cn.conn();

在其余代码中,使用 con 直接变量而不需要将其设置为任何其他连接,因此要么代码有效且你不需要 cn ,要么是错误的,你需要找到代码中的连接类,并在所有方法中使用它。

In the rest of your code, you use the con variable directly without needing to set it to any other connection, so either that code works and you don't need cn, or it is wrong, and you need to find the Connection class in your code and use it in all methods.


这篇关于错误1找不到类型或命名空间名称“连接”(您是否缺少using指令或程序集引用)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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