M
marcus
I have a problem trying to communicate between 2 namespaces, which I
have in the same file (news.aspx.cs). I'd like to create a new
variable in my first namespace "News" which is an instance of my class
Daddy.DBConnection.DBSQLConnection. But when I try to create my new
variable I get the error message: "expected class, delegate, enum,
interface, or struct".
I try create my new variable with the following line:
private Daddy.DBSQLConnection oConnection;
Anyone knows what I'm doing wrong?
----------- news.aspx.cs ---------------------------------------
namespace News
{
using System;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
public class News : System.Web.UI.Page
{
private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
}
}
}
namespace Daddy.DBConnection
{
using System;
using System.Configuration;
using System.Data.SqlClient;
/// <summary>
/// "Daddy.Connection" is a class for handeling data, such as XML,
DB, SQL etc
/// </summary>
public class DBSQLConnection
{
protected SqlConnection oConn;
protected SqlCommand oCmd;
protected string strConnection;
public DBSQLConnection() {
// Don't do nothing yet
}
public string GetConnectionString()
{
return ConfigurationSettings.AppSettings["ConnectionString"];
}
protected void Connect()
{
oConn.ConnectionString = GetConnectionString();
oConn.Open();
}
protected void CloseConnection()
{
if (oConn.State.ToString()=="Open")
{
oConn.ConnectionString = GetConnectionString();
oConn.Close();
}
}
public int ExecuteStmt(string strSQL)
{
oCmd.CommandText = strSQL;
oCmd.CommandType = CommandType.Text;
return oCmd.ExecuteNonQuery();
}
}
}
have in the same file (news.aspx.cs). I'd like to create a new
variable in my first namespace "News" which is an instance of my class
Daddy.DBConnection.DBSQLConnection. But when I try to create my new
variable I get the error message: "expected class, delegate, enum,
interface, or struct".
I try create my new variable with the following line:
private Daddy.DBSQLConnection oConnection;
Anyone knows what I'm doing wrong?
----------- news.aspx.cs ---------------------------------------
namespace News
{
using System;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
public class News : System.Web.UI.Page
{
private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
}
}
}
namespace Daddy.DBConnection
{
using System;
using System.Configuration;
using System.Data.SqlClient;
/// <summary>
/// "Daddy.Connection" is a class for handeling data, such as XML,
DB, SQL etc
/// </summary>
public class DBSQLConnection
{
protected SqlConnection oConn;
protected SqlCommand oCmd;
protected string strConnection;
public DBSQLConnection() {
// Don't do nothing yet
}
public string GetConnectionString()
{
return ConfigurationSettings.AppSettings["ConnectionString"];
}
protected void Connect()
{
oConn.ConnectionString = GetConnectionString();
oConn.Open();
}
protected void CloseConnection()
{
if (oConn.State.ToString()=="Open")
{
oConn.ConnectionString = GetConnectionString();
oConn.Close();
}
}
public int ExecuteStmt(string strSQL)
{
oCmd.CommandText = strSQL;
oCmd.CommandType = CommandType.Text;
return oCmd.ExecuteNonQuery();
}
}
}