G
Guest
Hi,
I'm getting the following message.when trying to connect to the server from
my client...
"No connection could be made as the server refused it".
Here is my serverside code..
TcpServerChannel tcp1 = new TcpServerChannel(49157);
ChannelServices.RegisterChannel(tcp1);
RemotingConfiguration.RegisterWellKnownServiceType(typeof(RemotableClass.DbConnect),"DbConnect",WellKnownObjectMode.SingleCall);
Here is my client code...
TcpClientChannel tcpClient = new TcpClientChannel();
ChannelServices.RegisterChannel(tcpClient);
RemotingConfiguration.RegisterWellKnownClientType(typeof(DbConnect),"tcp://10.236.230.117:49157/DbConnect");
Here is my remotable object...
public class DbConnect : MarshalByRefObject
{
public DataSet ExecuteQuery(string strQuery)
{
Console.Write("Starting to execute " +
"the query...");
// Create a SqlCommand object
// to represent the query
sqlConn.Open();
SqlCommand sqlcmd =
sqlConn.CreateCommand();
sqlcmd.Connection = sqlConn;
sqlcmd.CommandType = CommandType.Text;
sqlcmd.CommandText = strQuery;
// Create a SqlDataAdapter object
// to talk to the database
SqlDataAdapter sqlda = new SqlDataAdapter();
sqlda.SelectCommand = sqlcmd;
// Create a DataSet to hold the results
DataSet ds = new DataSet();
try
{
// Fill the DataSet
sqlda.Fill(ds, "Results");
}
catch (Exception ex)
{
Console.WriteLine(ex.Message,
"Error executing query");
}
Console.WriteLine("Done.");
return ds;
}}
Can anyone help me out.???????/ it's urgent...........
I'm getting the following message.when trying to connect to the server from
my client...
"No connection could be made as the server refused it".
Here is my serverside code..
TcpServerChannel tcp1 = new TcpServerChannel(49157);
ChannelServices.RegisterChannel(tcp1);
RemotingConfiguration.RegisterWellKnownServiceType(typeof(RemotableClass.DbConnect),"DbConnect",WellKnownObjectMode.SingleCall);
Here is my client code...
TcpClientChannel tcpClient = new TcpClientChannel();
ChannelServices.RegisterChannel(tcpClient);
RemotingConfiguration.RegisterWellKnownClientType(typeof(DbConnect),"tcp://10.236.230.117:49157/DbConnect");
Here is my remotable object...
public class DbConnect : MarshalByRefObject
{
public DataSet ExecuteQuery(string strQuery)
{
Console.Write("Starting to execute " +
"the query...");
// Create a SqlCommand object
// to represent the query
sqlConn.Open();
SqlCommand sqlcmd =
sqlConn.CreateCommand();
sqlcmd.Connection = sqlConn;
sqlcmd.CommandType = CommandType.Text;
sqlcmd.CommandText = strQuery;
// Create a SqlDataAdapter object
// to talk to the database
SqlDataAdapter sqlda = new SqlDataAdapter();
sqlda.SelectCommand = sqlcmd;
// Create a DataSet to hold the results
DataSet ds = new DataSet();
try
{
// Fill the DataSet
sqlda.Fill(ds, "Results");
}
catch (Exception ex)
{
Console.WriteLine(ex.Message,
"Error executing query");
}
Console.WriteLine("Done.");
return ds;
}}
Can anyone help me out.???????/ it's urgent...........