Hi all,
I'm new to C#, and have two pretty simple questions:
I have a class, in a .cs file by itself. I need to make use of the sole
function in this class in another .cs file. Here's the code, filename
bannertrack.cs
First question - the function "LogImpr" users ServerVariables["REMOTE_ADD R"]
+ "')"; The compiler tells me that this is not included in the namespace.
??
Second question - How do I call this function from another .cs file?
namespace internetdating. bannertracking. bannertrack
{
using System;
using System.Collecti ons;
using System.Componen tModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.Sess ionState;
using System.Web.UI;
using System.Web.UI.W ebControls;
using System.Web.UI.H tmlControls;
using System.Data.Odb c;
using System.Configur ation;
/// <summary>
/// STUFF HERE
/// </summary>
public class bannertrack: System.Web.UI.P age
{
public void LogImpr(System. Web.UI.WebContr ols.AdCreatedEv entArgs e)
{
String dsn = ConfigurationSe ttings.AppSetti ngs["idate"]; //Take
connectionstrin g from Web.Config
OdbcConnection myConnection = new OdbcConnection( dsn);
string InsertStr = "insert into impressions (LinkURL, Timestamp, IP) Values
('" + e.NavigateUrl +
"',NOW()" + ", '" + ServerVariables["REMOTE_ADD R"] + "')";
OdbcCommand myCommand = new OdbcCommand(Ins ertStr, myConnection);
myCommand.Conne ction.Open();
try
{
myCommand.Execu teNonQuery();
}
finally
{
myCommand.Conne ction.Close();
}
}
}
}
I'm new to C#, and have two pretty simple questions:
I have a class, in a .cs file by itself. I need to make use of the sole
function in this class in another .cs file. Here's the code, filename
bannertrack.cs
First question - the function "LogImpr" users ServerVariables["REMOTE_ADD R"]
+ "')"; The compiler tells me that this is not included in the namespace.
??
Second question - How do I call this function from another .cs file?
namespace internetdating. bannertracking. bannertrack
{
using System;
using System.Collecti ons;
using System.Componen tModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.Sess ionState;
using System.Web.UI;
using System.Web.UI.W ebControls;
using System.Web.UI.H tmlControls;
using System.Data.Odb c;
using System.Configur ation;
/// <summary>
/// STUFF HERE
/// </summary>
public class bannertrack: System.Web.UI.P age
{
public void LogImpr(System. Web.UI.WebContr ols.AdCreatedEv entArgs e)
{
String dsn = ConfigurationSe ttings.AppSetti ngs["idate"]; //Take
connectionstrin g from Web.Config
OdbcConnection myConnection = new OdbcConnection( dsn);
string InsertStr = "insert into impressions (LinkURL, Timestamp, IP) Values
('" + e.NavigateUrl +
"',NOW()" + ", '" + ServerVariables["REMOTE_ADD R"] + "')";
OdbcCommand myCommand = new OdbcCommand(Ins ertStr, myConnection);
myCommand.Conne ction.Open();
try
{
myCommand.Execu teNonQuery();
}
finally
{
myCommand.Conne ction.Close();
}
}
}
}
Comment