I create website on asp.net, is name ExpenseReport
First, I create 'DBConnect' class in App_Code by using namespace ExpenseReport
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Data.SqlClient;
namespace ExpenseReport
{
public partial class DBConnect
{
private SqlConnection objConn;
private SqlCommand objCmd;
private SqlTransaction Trans;
private String strConnString;
private String strCommandString;
private static String empID;
private static String empName;
public DBConnect()
{
strConnString = ConfigurationManager.ConnectionStrings["Con"].ToString();
}
public SqlDataReader QueryDataReader(String strSQL)
{
SqlDataReader dtReader;
objConn = new SqlConnection();
objConn.ConnectionString = strConnString;
objConn.Open();
objCmd = new SqlCommand(strSQL, objConn);
dtReader = objCmd.ExecuteReader();
return dtReader; //*** Return DataReader ***//
}
public DataSet QueryDataSet(String strSQL)
{
DataSet ds = new DataSet();
SqlDataAdapter dtAdapter = new SqlDataAdapter();
objConn = new SqlConnection();
objConn.ConnectionString = strConnString;
objConn.Open();
objCmd = new SqlCommand();
objCmd.Connection = objConn;
objCmd.CommandText = strSQL;
objCmd.CommandType = CommandType.Text;
dtAdapter.SelectCommand = objCmd;
dtAdapter.Fill(ds);
return ds; //*** Return DataSet ***//
}
}
}
Second, I create all page that I needs and all page use DBConnect class
using System;
using System.Data;
using System.Configuration;
using System.Collections;
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.Common;
namespace ExpenseReport
{
public partial class Index : System.Web.UI.Page
{
DBConnect DB = new DBConnect();
bool isLogin = false;
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
IsCheck(txtUsername.Text, txtPassword.Text);
}
private void IsCheck(string username, string password)//ตรวจสอบค่าที่รับเข้ามา
{
string role = "";
string empName = "";
string empID = "";
string SQL = "SELECT empUsername, empPassword, empType, empID, empName FROM Employee WHERE empUsername = '" + username + "' AND empPassword = '" + password + "'";
DataSet ds;
ds = DB.QueryDataSet(SQL);
if (ds.Tables[0].Rows.Count > 0)
{
if (username == ds.Tables[0].Rows[0]["empUsername"].ToString())
{
if (password == ds.Tables[0].Rows[0]["empPassword"].ToString())
{
isLogin = true;
role = ds.Tables[0].Rows[0]["empType"].ToString();
empName = ds.Tables[0].Rows[0]["empName"].ToString();
empID = ds.Tables[0].Rows[0]["empID"].ToString();
}
else
{
isLogin = false;
}
}
else
{
isLogin = false;
}
}
else
{
isLogin = false;
}
if (isLogin)
{
MyTicket(username, role, empName, empID); //เรียกใช้ ticket
}
else
{
Label1.Text = "Login Failed";
}
}
}
}
It's OK when I runs on my computer.
After that, I upload website into my hosting (host:godaddy), It's error
Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: CS0246: The type or namespace name 'DBConnect' could not be found (are you missing a using directive or an assembly reference?)
Why???
What could I do?
Please suggest me !!