找不到"dbconnection" [英] 'dbconnection' could not be found

查看:109
本文介绍了找不到"dbconnection"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下是我的代码文件.

我收到以下错误:

Following is my code file.

I am getting the following error:

The type or namespace name ''dbconnection'' could not be found (are you missing a using directive or an assembly reference?)<br />


using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
using System.Data.Common;
using System.Collections;

public partial class Enquiry_Ind : System.Web.UI.Page
{
    dbconnection dbcon = new dbconnection();

    protected void Page_Load(object sender, EventArgs e)
    {      
        
    }
    protected void Ind_Submit_Click(object sender, EventArgs e)
    {
        dbcon.opencon();
       
        SqlCommand cmd = new SqlCommand("Insert into Indivisual(Name,Age,Mobile_No,Email_Id,Occupation,Location) values(''" + Ind_Name.Text + "'',''" + Ind_Age.Text + "'',''" + Ind_Mobil_No.Text + "'', ''" + Ind_Email_Id.Text + "''  ,''" + Ind_Occ.SelectedItem.Value + "'',''"+Ind_Loc.SelectedItem.Value+"'')", dbcon.con);
        cmd.ExecuteNonQuery();
        dbcon.closecon();
        SqlCommand cmd1 = new SqlCommand("select max(id) from login_master", dbcon.con );
        int id1 = Convert.ToInt32(cmd1.ExecuteScalar());
        id1 = id1 + 1;
        string name = Ind_Name.Text;
        string user_id;
        string occ = Ind_Occ.SelectedValue;

        if (Ind_Occ.SelectedValue == "Business/Entrepreneur")
        {
            occ = occ.Substring(0, 2) + occ.Substring(9, 2);
        }
        else if (Ind_Occ.SelectedValue == "Service-Private")
        {
            occ = occ.Substring(0, 2) + occ.Substring(8, 2);
        }
        else if (Ind_Occ.SelectedValue == "HouseWife")
        {
            occ = occ.Substring(0, 2) + occ.Substring(5, 2);
        }
        else if (Ind_Occ.SelectedValue == "Service-Govt/Psu/Defence/Army/Armed Force/Civil Services")
        {
            occ = occ.Substring(0, 2) + occ.Substring(7, 2);
        }
        else
        {
            occ = occ.Substring(0, 4);
        }
        user_id = name.Substring(0, 3) + occ + id1;
        string allowedChars = "abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNOPQRSTUVWXYZ0123456789!@$?_-";
        char[] chars = new char[6];
        Random rd = new Random();
        for (int i = 0; i < 6; i++)
        {
            chars[i] = allowedChars[rd.Next(0, allowedChars.Length)];
        }
        string individual = "Individual";
        string pass = new string(chars);
        Session["user"] = user_id.ToString();
        Session["passwd"] = pass;
        SqlCommand cmd2 = new SqlCommand("INSERT INTO login_master (id,User_id,password,user_type) VALUES ( ''" + id1 + "'' , ''" + user_id + "'', ''" + pass + "'', ''" + individual + "'' )", dbcon .con );
        cmd2.ExecuteNonQuery();
        Session.Add("LoginID", user_id);
        Session.Add("Password", pass);
        Server.Transfer("~/Enquiry/Thank u.aspx");
        
    
    }
    protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
    {

    }
}




[Edited]代码被包装在"pre"标签中.[/Edited]




Code is wrapped in "pre" tags[/Edited]

推荐答案

?_-; char [] chars =新的char [6]; 随机rd =新的Random(); 对于(int i = 0; i< 6; i ++) { chars [i] = allowedChars [rd.Next(0,allowedChars.Length)]; } 字符串个人=个人"; 字符串通过=新字符串(字符); 会话[用户"] = user_id.ToString(); Session ["passwd"] =通过; SqlCommand cmd2 =新的SqlCommand("INSERT INTO login_master(id,User_id,password,user_type)VALUES(""+ id1 +"'',''"+ user_id +"'',``"+ pass +"'' ,''"+个人+"''),dbcon .con); cmd2.ExecuteNonQuery(); Session.Add("LoginID",user_id); Session.Add("Password",pass); Server.Transfer(〜/查询/谢谢u.aspx"); } 受保护的void DropDownList1_SelectedIndexChanged(对象发送者,EventArgs e) { } }
?_-"; char[] chars = new char[6]; Random rd = new Random(); for (int i = 0; i < 6; i++) { chars[i] = allowedChars[rd.Next(0, allowedChars.Length)]; } string individual = "Individual"; string pass = new string(chars); Session["user"] = user_id.ToString(); Session["passwd"] = pass; SqlCommand cmd2 = new SqlCommand("INSERT INTO login_master (id,User_id,password,user_type) VALUES ( ''" + id1 + "'' , ''" + user_id + "'', ''" + pass + "'', ''" + individual + "'' )", dbcon .con ); cmd2.ExecuteNonQuery(); Session.Add("LoginID", user_id); Session.Add("Password", pass); Server.Transfer("~/Enquiry/Thank u.aspx"); } protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e) { } }




代码被包装在"pre"标签中[/编辑]




Code is wrapped in "pre" tags[/Edited]


尝试此

try this

SqlConnection Con = new SqlConnection("Your Connection String");


我很想知道为什么您要使用dbconnection,就像 Mahen 建议您在项目中导入System.Data.dll一样,然后您需要使用SqlConnection类而不是dbconnection.
看看那里有[SqlConnection类] [ ^ ]了解更多详细信息.
I am eager to know why are you using dbconnection whatever as Mahen suggested you should import System.Data.dll in your project and then you need to use SqlConnection Class instead of dbconnection.
take a look there-[SqlConnection Class][^] for more details.


这篇关于找不到"dbconnection"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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