Our network nazi doesn't want us running a webserver on the server that
has a connection to the campus database so we created a remote object
that runs as a windows service. The windows service runs on the server
with a connection to the campus database and we make calls to it. My
question is, how best to connect to this object via asp.net, in an aspx
page?. The example I had used a console ap to connect and that works,
but we want to connect to the remote object from an asp.net web page.
Here is the remote object
using System;
using System.Data;
using System.Data.Sql Client;
using System.Diagnost ics;
namespace RemoteObject
{
/// <summary>
/// Summary description for Class1.
/// </summary>
public class Relay : MarshalByRefObj ect
{
private SqlConnection mySqlConn = new SqlConnection(" Network
Library=DBMSSOC N;Data Source=server;I nitial Catalog=proddb; User
ID=user;Passwor d=password;");
private SqlCommand mySqlComm = new SqlCommand();
public Relay()
{
//
// TODO: Add constructor logic here
//
}
public String GetTestString(S tring str)
{
return str;
}
public DataSet GetDataSet(Stri ng strSqlQry)
{
DataSet myDS = new DataSet();
SqlDataAdapter myDA = new SqlDataAdapter( strSqlQry,
mySqlConn);
myDA.Fill(myDS) ;
myDA.Dispose();
mySqlConn.Close ();
return myDS;
}
public SqlDataReader GetDataReader(S tring strSqlQry)
{
mySqlComm.Comma ndText = strSqlQry;
mySqlComm.Conne ction = mySqlConn;
mySqlConn.Open( );
SqlDataReader myDR = mySqlComm.Execu teReader
(CommandBehavio r.CloseConnecti on);
return myDR;
}
}
}
And the config file for the windows service looks like
<configuratio n>
<system.runtime .remoting>
<application name="RemoteHos tService">
<service>
<wellknown type="RemoteObj ect.Relay, RemoteObject"
objectUri="Remo teObject.Relay"
mode="Singleton " />
</service>
<channels>
<channel ref="http" port="8085">
<serverProvider s>
<formatter ref="soap" />
</serverProviders >
</channel>
</channels>
</application>
</system.runtime. remoting>
</configuration>
And here is a working example of the console ap that can connect
remotely:
using System;
using System.Runtime. Remoting.Channe ls;
using System.Runtime. Remoting.Channe ls.Http;
using RemoteObject;
namespace RemotingClient
{
/// <summary>
/// Summary description for Class1.
/// </summary>
class RemoteClient
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main(string[] args)
{
//
// TODO: Add code to start application here
//
HttpChannel chan = new HttpChannel();
ChannelServices .RegisterChanne l(chan);
Relay r = (Relay)Activato r.GetObject(
typeof(RemoteOb ject.Relay),
"http://server:8085/RemoteObject.Re lay");
if (r == null)
System.Console. WriteLine("Coul d not locate
server");
else
{
System.Data.Sql Client.SqlDataR eader _sqlReader;
_sqlReader = r.GetDataReader ("select [Name] from
dbo.CMN_Terms WHERE CMN_TermsID=1") ;
_sqlReader.Read ();
Console.WriteLi ne(_sqlReader["Name"].ToString
());
}
}
}
}
This works, but we've been having trouble connecting to the remote
object 'relay' from an aspx page which is what we need. How does one
connect from an aspx page to a remote object? 1 2607
there should be no difference (unless the remote host is iis and is using
security). is the port blocked to the webserver? try to use the simpler tcp
transport.
also you should not pass a datareader reference, you should return a dataset
or datatable, or you'll end up with resource leaks. if the web page fails to
empty the reader, it will leave a dangling connection.
-- bruce (sqlwork.com)
"Jim Bayers" <sp**@spamity.s pam> wrote in message
news:Xn******** *************** ******@207.46.2 48.16...
| Our network nazi doesn't want us running a webserver on the server that
| has a connection to the campus database so we created a remote object
| that runs as a windows service. The windows service runs on the server
| with a connection to the campus database and we make calls to it. My
| question is, how best to connect to this object via asp.net, in an aspx
| page?. The example I had used a console ap to connect and that works,
| but we want to connect to the remote object from an asp.net web page.
| Here is the remote object
|
| using System;
| using System.Data;
| using System.Data.Sql Client;
| using System.Diagnost ics;
|
| namespace RemoteObject
| {
| /// <summary>
| /// Summary description for Class1.
| /// </summary>
| public class Relay : MarshalByRefObj ect
| {
| private SqlConnection mySqlConn = new SqlConnection(" Network
| Library=DBMSSOC N;Data Source=server;I nitial Catalog=proddb; User
| ID=user;Passwor d=password;");
| private SqlCommand mySqlComm = new SqlCommand();
|
| public Relay()
| {
| //
| // TODO: Add constructor logic here
| //
| }
| public String GetTestString(S tring str)
| {
| return str;
| }
|
| public DataSet GetDataSet(Stri ng strSqlQry)
| {
| DataSet myDS = new DataSet();
| SqlDataAdapter myDA = new SqlDataAdapter( strSqlQry,
| mySqlConn);
| myDA.Fill(myDS) ;
| myDA.Dispose();
| mySqlConn.Close ();
|
| return myDS;
| }
|
| public SqlDataReader GetDataReader(S tring strSqlQry)
| {
| mySqlComm.Comma ndText = strSqlQry;
| mySqlComm.Conne ction = mySqlConn;
| mySqlConn.Open( );
| SqlDataReader myDR = mySqlComm.Execu teReader
| (CommandBehavio r.CloseConnecti on);
|
| return myDR;
| }
|
| }
|
| }
|
| And the config file for the windows service looks like
|
| <configuratio n>
| <system.runtime .remoting>
| <application name="RemoteHos tService">
| <service>
| <wellknown type="RemoteObj ect.Relay, RemoteObject"
| objectUri="Remo teObject.Relay"
| mode="Singleton " />
| </service>
| <channels>
| <channel ref="http" port="8085">
| <serverProvider s>
| <formatter ref="soap" />
| </serverProviders >
| </channel>
| </channels>
| </application>
| </system.runtime. remoting>
| </configuration>
|
| And here is a working example of the console ap that can connect
| remotely:
|
| using System;
| using System.Runtime. Remoting.Channe ls;
| using System.Runtime. Remoting.Channe ls.Http;
| using RemoteObject;
|
| namespace RemotingClient
| {
| /// <summary>
| /// Summary description for Class1.
| /// </summary>
| class RemoteClient
| {
| /// <summary>
| /// The main entry point for the application.
| /// </summary>
| [STAThread]
| static void Main(string[] args)
| {
| //
| // TODO: Add code to start application here
| //
| HttpChannel chan = new HttpChannel();
| ChannelServices .RegisterChanne l(chan);
|
| Relay r = (Relay)Activato r.GetObject(
| typeof(RemoteOb ject.Relay),
| "http://server:8085/RemoteObject.Re lay");
| if (r == null)
| System.Console. WriteLine("Coul d not locate
| server");
| else
| {
| System.Data.Sql Client.SqlDataR eader _sqlReader;
| _sqlReader = r.GetDataReader ("select [Name] from
| dbo.CMN_Terms WHERE CMN_TermsID=1") ;
| _sqlReader.Read ();
| Console.WriteLi ne(_sqlReader["Name"].ToString
| ());
|
| }
|
| }
| }
| }
|
| This works, but we've been having trouble connecting to the remote
| object 'relay' from an aspx page which is what we need. How does one
| connect from an aspx page to a remote object? This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Thomas Scheiderich |
last post by:
I get an error from trying to connect to my Sql6.5 server (which is why
I am using Ole). It says the server doesn't exist or the password is
wrong. I can't understand that because I use essetially the same
connection scripts on my ASP pages and it works fine.
Here is my ASP connection that works fine:
*****************************************************************
Set connectionToDatabase=Server.CreateObject("ADODB.Connection")...
|
by: Jeff |
last post by:
I have an ASP.NET web page accessing a SQL database. I've used VS to build
the app and stored it in the eNPTest02 directory of my localhost on my
development machine. The database is on the web. I've found a way that
works on the web, and I'm trying to get it to also work in debug mode in the
IDE. The "on the web" page and my SQL database are hosted by a third party
(on separate servers).
Since debug mode opens IE and loads my page...
|
by: Ann Marinas |
last post by:
Hi there,
I am currently developing an ASP.NET program that connects to a SQL Server
2000 database. I also have SQL Server 2005 Express installed on the same
local machine.
Prior to installing SQL Server 2005, my apps were working and is connecting
flawlessly to a database on the SQL Server 2000. Now, whenever I connect to
the same database with the 2005 version installed, I keep on getting this
error:
|
by: Todd Brewer |
last post by:
Windows Server 2000
ASP.NET 2.0
SQL Server 2000 (on a physically seperate server)
I moved an ASP.NET 2.0 application from a development server to production,
and am getting the following error:
System.Data.SqlClient.SqlException: An error has occurred while establishing
a connection to the server. When connecting to SQL Server 2005, this failure
may be caused by the fact that under the default settings SQL Server does not
|
by: =?Utf-8?B?U3JpcmFtIE1hbGxhanlvc3VsYQ==?= |
last post by:
Hi,
I am not sure whether this is the correct newsgroup where I need to post my
question. Let me know where I need to post for a quick response.
I get the following error when I try to connect to SQL 2005 from my ASP.Net
2.0 application.
System.Web.Services.Protocols.SoapException: Server was unable to process
request. ---System.Data.SqlClient.SqlException: An error has occurred while
| |
by: JDS |
last post by:
I am a newbie to asp.net but have done traditional vb, asp and vb.net
- please forgive any dumb questions!
As a test I have a very simple page (Default.aspx) with a single
button which then redirects to a second page (MemberReport.aspx) using
Response.Redirect. I have the code working on a remote machine as
localhost and the same code running on the server as localhost both
with no problems. However, when I try to access the pages on the...
|
by: samadams_2006 |
last post by:
Hello,
I have a problem that I'm hoping someone will be able to help me
resolve.
1) I have a C# Web Site in which I connect to the database: "Install
Microsoft SQL Server 2005 Express Edition" via the link on:
http://msdn2.microsoft.com/en-us/express/bb410792.aspx
|
by: Me LK |
last post by:
I did a search but could not find an aswer that worked so here it
goes.
I just did an upgrade from 2003 to vs 2005 express. I am using a
remote sql server 2000. I specifically upgrade to make use of the
login control. Everything upgraded fine and the site is working on my
local machine.
It seems that my site is trying to connect to a local database. I need
it to attach to a remote database. I added a connection string to
|
by: aboutjav.com |
last post by:
Hi,
I need some help. I am getting this error after I complete the asp.net
register control and click on the continue button. It crashed when it
tries to get
it calls this Profile property
((string)(this.GetPropertyValue("Address1")));
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |