无法找到类型或命名空间“连接”。(是否缺少指令或程序集引用) [英] type or namespace 'connection 'could not be found.(are u missing directive or assembly reference)
本文介绍了无法找到类型或命名空间“连接”。(是否缺少指令或程序集引用)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
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;
using System.Configuration;
namespace WebRole1
{
public partial class login1 : System.Web.UI.Page
{
connection cn = new connection();
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btn_Login_Click(object sender, EventArgs e)
{
SqlConnection con = cn.conn();
con.Open();
SqlCommand cmd = new SqlCommand("select count(*) from login where User_ID=@NAME and Password=@PWD", con);
cmd.Parameters.AddWithValue("@NAME", txt_loginID.Text);
cmd.Parameters.AddWithValue("@PWD", txt_login_pwd.Text);
int cnt;
Object abc = cmd.ExecuteScalar();
con.Close();
// Response.Cookies["test"].Value = txt_loginID.Text;
//Response.Cookies["test"].Expires = DateTime.Now.AddYears(30);
cnt = Convert.ToInt32(abc.ToString());
if (cnt > 0)
{
Session["user"] =
//"hai ra";
txt_loginID.Text;
Response.Redirect("~/Home.aspx");
}
else
{
txt_login_pwd.Text = "";
txt_loginID.Text = "";
lbl_mgs.Text = "invalid userid";
lbl_mgs.Visible = true;
}
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Configuration;
using System.Data.SqlClient;
/// <summary>
/// Summary description for Connection1
/// </summary>
public class Connection1
{
public Connection1()
{
//
// TODO: Add constructor logic here
//
}
String str = RoleEnvironment.GetConfigurationSettingValue("sri");
SqlConnection con;
public SqlConnection conn()
{
con = new SqlConnection(str);
return con;
}
}
my probelm每当bulid项目然后发生错误是类型或命名空间'连接'无法找到(你是否缺少程序集或指令)。这是windows azure项目和命名空间是web角色。
请帮助我。
my probelm whenever bulid project then error occur is "type or namespace 'connection 'could not be found(are u missing assembly or directive).this is windows azure project and namespace is web role.
please help me.
推荐答案
更改以下行...
Change below line...
connection cn = new connection();
要
To
Connection1 cn = new Connection1();
这篇关于无法找到类型或命名空间“连接”。(是否缺少指令或程序集引用)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文