473,662 Members | 2,575 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Connecting to a remote sql server

Hi NG,

I try to connect to a remote MS-SQL-Server 2000 from an ASP.NET
application. Here's how I do it:

private void ConnectToDataba se(string host, string dataBaseName, string
userID, string password)
{
string connectionStrin g;

connectionStrin g = "Initial Catalog=" + dataBaseName + ";";
connectionStrin g += "Data Source=" + host + ";";
connectionStrin g += "Integrated Security=SSPI;" ;
connectionStrin g += "User ID=" + userID + ";";
connectionStrin g += "Password=" + password + ";";

_myConnection = new SqlConnection() ;
_myConnection.C onnectionString = connectionStrin g;
try
{
_myConnection.O pen();
}
catch (Exception e)
{
throw e;
}
}

If I use this module in a windows-gui c# project, it works fine. But in
an ASP.NET application I get the error: Login failed for user
'domainname\com putername$'
I have double checked User ID and Password in the connetion string, but
they were correct.

Any ideas on that?

Thanks,
Frank
Nov 19 '05 #1
3 1450
I see from your code that you are using SQL Server's integrated security. It
means that SQL Server uses the account under which the application is
running, and not the user ID and password quoted in the connection string,
to decide whether it will let it in or not.

ASP.NET applications run under a local machine account named ASPNET. You
need to give this account the necessary rights. If your database were
located on the same computer as the executable then I'd advise you to make
the account a member of the Administrators" group. But since your database
is located on a remote computer, I'm not sure what would be the best thing
to do. Maybe impersonation?

Viele Grüße nach Leipzig,
Michal

--
Michal Boleslav Mechura
va******@hotmai l.com

"Frank Schumacher" <fs*******@info rmatik.uni-leipzig.de> wrote in message
news:%2******** *******@TK2MSFT NGP12.phx.gbl.. .
Hi NG,

I try to connect to a remote MS-SQL-Server 2000 from an ASP.NET
application. Here's how I do it:

private void ConnectToDataba se(string host, string dataBaseName, string
userID, string password)
{
string connectionStrin g;

connectionStrin g = "Initial Catalog=" + dataBaseName + ";";
connectionStrin g += "Data Source=" + host + ";";
connectionStrin g += "Integrated Security=SSPI;" ;
connectionStrin g += "User ID=" + userID + ";";
connectionStrin g += "Password=" + password + ";";

_myConnection = new SqlConnection() ;
_myConnection.C onnectionString = connectionStrin g;
try
{
_myConnection.O pen();
}
catch (Exception e)
{
throw e;
}
}

If I use this module in a windows-gui c# project, it works fine. But in an
ASP.NET application I get the error: Login failed for user
'domainname\com putername$'
I have double checked User ID and Password in the connetion string, but
they were correct.

Any ideas on that?

Thanks,
Frank

Nov 19 '05 #2
because you set integrated security on in the connection string, the
user/password setting are ignored, they are for sqlserver's standard
security. the webconfig supports setting the nt user account and password,
see <identity impersonate="tr ue" username='domai n\user" password="passw ord"
/>

-- bruce (sqlwork.com)
"Frank Schumacher" <fs*******@info rmatik.uni-leipzig.de> wrote in message
news:%2******** *******@TK2MSFT NGP12.phx.gbl.. .
| Hi NG,
|
| I try to connect to a remote MS-SQL-Server 2000 from an ASP.NET
| application. Here's how I do it:
|
| private void ConnectToDataba se(string host, string dataBaseName, string
| userID, string password)
| {
| string connectionStrin g;
|
| connectionStrin g = "Initial Catalog=" + dataBaseName + ";";
| connectionStrin g += "Data Source=" + host + ";";
| connectionStrin g += "Integrated Security=SSPI;" ;
| connectionStrin g += "User ID=" + userID + ";";
| connectionStrin g += "Password=" + password + ";";
|
| _myConnection = new SqlConnection() ;
| _myConnection.C onnectionString = connectionStrin g;
| try
| {
| _myConnection.O pen();
| }
| catch (Exception e)
| {
| throw e;
| }
| }
|
| If I use this module in a windows-gui c# project, it works fine. But in
| an ASP.NET application I get the error: Login failed for user
| 'domainname\com putername$'
| I have double checked User ID and Password in the connetion string, but
| they were correct.
|
| Any ideas on that?
|
| Thanks,
| Frank
Nov 19 '05 #3
Thanks Bruce and Michal,
that has done it :)

Ciao,
Frank

bruce barker wrote:
because you set integrated security on in the connection string, the
user/password setting are ignored, they are for sqlserver's standard
security. the webconfig supports setting the nt user account and password,
see <identity impersonate="tr ue" username='domai n\user" password="passw ord"
/>

-- bruce (sqlwork.com)

Nov 19 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
3245
by: stabbert | last post by:
We are running DB2 UDB 8.1.6 in a partitioned environment where we have 8 physical nodes. We have a process that remotely connects to each individual node and loads some data. By setting the DB2NODE variable to a different value then the coordinator node is the only way I am aware for a remote application to do this so I am making the assumption that is how this application connects. What I am more interested in is that after logging...
1
2602
by: Jim Bayers | last post by:
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...
5
2374
by: bill | last post by:
I am having difficulties connecting to a remote Sql server database in VB.net. Lets say my remote server is found at 255.255.255.255 and its name is MyServer. The database is called MyDatabase. I drap my SQLDataAdapter on to the form and set up a new connection at the wizard. I am putting the IP address of my server under server name and entering my login and password. I get an access denied. Sql Server Error: 17.
0
1665
by: acwomble | last post by:
I am working with a database on another system via a ssh tunnel using plink. We have setup an alias the local system for the remote database. I am able to connect and work from within Visual Studio if I connect to the remote database using with "SQL Server" as the data source and ".NET Framework Data Provider for OLEDB" as the data provider . If I change the data provider to ".NET Framework Data Provider for SQL Server" I get the...
0
3917
by: Suresh | last post by:
Hi Guys I have Db2 server installed on remote server. i am connecting to that remote server by using VPN. I want to connect that remote DB2 server instance using my local machine DB2 development client. Bur Its gives me following error message. I searched lots of things on net and tried on remote server but i didnt got suceess. Can any one tell me how to set TCP\IP connection protocol on server for particular instance. Becuase I think
8
4365
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
2
4953
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
1
1647
by: SayamiSuchi | last post by:
Hi.. I have been assigned to make a database in some remote machine.The machine has MSSQL 2005.I need to connect to that remote machine's sql server via my pc using my SQL Management express.I do have that computer's IP address(say,123.456.789.000),and the username and password.But when i try to connect to the server ,I get the following error: Cannot connect to 123.456.789.000\sqlexpress An error has occured while establishing a...
3
5736
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
0
2001
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")));
0
8432
marktang
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...
0
8344
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8764
jinu1996
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...
1
8546
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8633
tracyyun
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...
0
7367
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6186
isladogs
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...
0
5654
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4180
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 using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.