0
我得到這個錯誤CS1061:'System.Data.OracleClient.OracleConnection'沒有包含'searchDBSet'的定義,也沒有包含接受第一個的searchDBSet的擴展方法可以找到'System.Data.OracleClient.OracleConnection'類型的參數(缺少使用指令或程序集引用?)。我敢肯定,我有System.Data參考,我想我有繼承的問題,因爲我的代碼是不是recognized.Can請人幫忙解決這個issue.Thank你System.Data.OracleClient.OracleConnection不包含定義
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Security;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Data.OracleClient;
public partial class users_Login : System.Web.UI.Page
{
OracleConnection oc = new OracleConnection("Data Source=**;Persist Security Info=True;User ID=****;Password=****;Unicode=false");
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btnLogin_Click(object sender, EventArgs e)
{
int flag = 0;
string user_name = loginUserName.Text;
string password = loginPassword.Text;
string qry = "select user_name,password from users where user_name='" + user_name + "' and password='" + password + "'";
DataSet set = oc.searchDBSet(qry);
foreach (DataRow dr in set.Tables[0].Rows)
{
flag = 1;
}
if (flag == 1)
{
FormsAuthentication.RedirectFromLoginPage(user_name, true);
}
else
{
lblMessage.Visible = true;
}
}
}
my class1 code
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using System.Data.OracleClient;
public class Oracleconection
{
string connectionString;
private System.Data.OracleClient.OracleConnection connection;
private System.Data.OracleClient.OracleDataAdapter adapter;
private System.Data.OracleClient.OracleCommand command;
public Oracleconection(string host, string dbname, string username, String password)
{
try
{
//this.connectionString = "Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST="+host+")(PORT=1521)))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME="+dbname+")));User Id="+username+";Password="+password+";";
this.connectionString = "Data Source=****;Persist Security Info=True;User ID=****;Password=****;Unicode=false";
this.connection = new System.Data.OracleClient.OracleConnection(this.connectionString);
this.connection.Open();
this.command = connection.CreateCommand();
Console.WriteLine("Connected");
}
catch (Exception e)
{
Console.WriteLine("Error while connecting:" + e.Message);
}
}
public DataTable searchDB(string query)
{
DataTable table = new DataTable();
try
{
this.command.CommandText = query;
this.adapter = new System.Data.OracleClient.OracleDataAdapter(command);
this.adapter.Fill(table);
}
catch (Exception e)
{
Console.Write("Error:" + e);
}
return table;
}
public DataSet searchDBSet(string query)
{
DataSet ds = new DataSet();
try
{
this.command.CommandText = query;
this.adapter = new System.Data.OracleClient.OracleDataAdapter(command);
this.adapter.Fill(ds);
}
catch (Exception e)
{
Console.Write("Error:" + e);
}
return ds;
}
public int updateDB(string query)
{
try
{
this.command.CommandText = query;
return this.command.ExecuteNonQuery();
}
catch (Exception e)
{
Console.Write("Error:" + e);
return -1;
}
}
public void close()
{
connection.Close();
}
}
你想繼承什麼課?我沒有看到名爲'class1'的類。 –
第1類是文件的名稱。在頁面內部,我將公共類1的呼叫名稱更改爲public class Oracleconection,如您在我的第二個代碼中所見 – user2884405
我已更改問題以使其更清楚。 – user2884405