MSDOTnet.org Forum Index
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Error in remote connection to SQL Server

 
Post new topic   Reply to topic    MSDOTnet.org Forum Index -> ASPNet
Author Message
glbdev



Joined: 08 Aug 2007
Posts: 1

PostPosted: Thu Dec 13, 2007 1:18 pm    Post subject: Error in remote connection to SQL Server Reply with quote

Hi. I am having an problem connecting to a remote SQL Server. Other
applications (using access) are connection to it but I cannot get it
to work through ASP.Net.

Here is my connection string:

Public Function StringConnection() As String
Return "Server=myservername;Database=mydatabasename;User
ID=myid;Password=mypassword;"
End Function

Everything works fine if I use my local DB so I am sure it's not the
code and other applications can connect to the server so I am pretty
sure it's not SQL Server, something must be wrong in the connection
string. The sample above is just the latest version I've tried. I'm
only posting it in the hope that someone can show me the correct
string for a remote connection.

Any ideas?

Thanks,
Steve

Archived from group: microsoft>public>dotnet>framework>aspnet
Back to top
View user's profile Send private message
Peter Bromberg [C# MVP]



Joined: 31 Oct 2007
Posts: 22

PostPosted: Thu Dec 13, 2007 3:04 pm    Post subject: RE: Error in remote connection to SQL Server Reply with quote

You'd be a lot better off if you didn't hard-code the connection string into
your compiled code. Better to use the app.config / web.config
ConfigurationManager.ConnectionStrings["myConnectionString"].ConnectionString
or an section instead. This makes your application more
portable.

If, as you say, other applications can connect to the server ( i assume
remotely) then why don't you take a look at their connection strings?
-- Peter
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
MetaFinder: http://www.blogmetafinder.com


"glbdev@yahoo.com" wrote:

> Hi. I am having an problem connecting to a remote SQL Server. Other
> applications (using access) are connection to it but I cannot get it
> to work through ASP.Net.
>
> Here is my connection string:
>
> Public Function StringConnection() As String
> Return "Server=myservername;Database=mydatabasename;User
> ID=myid;Password=mypassword;"
> End Function
>
> Everything works fine if I use my local DB so I am sure it's not the
> code and other applications can connect to the server so I am pretty
> sure it's not SQL Server, something must be wrong in the connection
> string. The sample above is just the latest version I've tried. I'm
> only posting it in the hope that someone can show me the correct
> string for a remote connection.
>
> Any ideas?
>
> Thanks,
> Steve
>
Back to top
View user's profile Send private message
Peter Bromberg [C# MVP]



Joined: 31 Oct 2007
Posts: 22

PostPosted: Thu Dec 13, 2007 3:16 pm    Post subject: RE: Error in remote connection to SQL Server Reply with quote

If you are using the "Web Site" project model, you need to place all your
global.asax code in global.asax.cs, in the App_Code directory

You must include this at the top of global.asax.cs :

public class Global : System.Web.HttpApplication

.....and include this directive in global.asax :


the same for vb :


With a Web Application Project, this is not necessary and you can use the
normal (like in 1.1 that is) codebehind deal.
-- Peter
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
MetaFinder: http://www.blogmetafinder.com


"glbdev@yahoo.com" wrote:

> Hi. I am having an problem connecting to a remote SQL Server. Other
> applications (using access) are connection to it but I cannot get it
> to work through ASP.Net.
>
> Here is my connection string:
>
> Public Function StringConnection() As String
> Return "Server=myservername;Database=mydatabasename;User
> ID=myid;Password=mypassword;"
> End Function
>
> Everything works fine if I use my local DB so I am sure it's not the
> code and other applications can connect to the server so I am pretty
> sure it's not SQL Server, something must be wrong in the connection
> string. The sample above is just the latest version I've tried. I'm
> only posting it in the hope that someone can show me the correct
> string for a remote connection.
>
> Any ideas?
>
> Thanks,
> Steve
>
Back to top
View user's profile Send private message
Jeff Dillon



Joined: 07 Dec 2007
Posts: 1

PostPosted: Thu Dec 13, 2007 3:26 pm    Post subject: Re: Error in remote connection to SQL Server Reply with quote

http://www.connectionstrings.com/

wrote in message @d4g2000prg.googlegroups.com...
> Hi. I am having an problem connecting to a remote SQL Server. Other
> applications (using access) are connection to it but I cannot get it
> to work through ASP.Net.
>
> Here is my connection string:
>
> Public Function StringConnection() As String
> Return "Server=myservername;Database=mydatabasename;User
> ID=myid;Password=mypassword;"
> End Function
>
> Everything works fine if I use my local DB so I am sure it's not the
> code and other applications can connect to the server so I am pretty
> sure it's not SQL Server, something must be wrong in the connection
> string. The sample above is just the latest version I've tried. I'm
> only posting it in the hope that someone can show me the correct
> string for a remote connection.
>
> Any ideas?
>
> Thanks,
> Steve
Back to top
View user's profile Send private message
sloan



Joined: 08 Aug 2007
Posts: 28

PostPosted: Thu Dec 13, 2007 6:52 pm    Post subject: Re: Error in remote connection to SQL Server Reply with quote

A remote server must be enabled to receive remote connections.

This is via the "Sql Server Surface Area Configuration".

if that is setup properly, there are 2 things.


www.connectionstrings.com

keeping playing with them.

and (default)....the port is 1433..you have to make sure this is open...via
a firewall program you are using.




wrote in message @d4g2000prg.googlegroups.com...
> Hi. I am having an problem connecting to a remote SQL Server. Other
> applications (using access) are connection to it but I cannot get it
> to work through ASP.Net.
>
> Here is my connection string:
>
> Public Function StringConnection() As String
> Return "Server=myservername;Database=mydatabasename;User
> ID=myid;Password=mypassword;"
> End Function
>
> Everything works fine if I use my local DB so I am sure it's not the
> code and other applications can connect to the server so I am pretty
> sure it's not SQL Server, something must be wrong in the connection
> string. The sample above is just the latest version I've tried. I'm
> only posting it in the hope that someone can show me the correct
> string for a remote connection.
>
> Any ideas?
>
> Thanks,
> Steve

Back to top
View user's profile Send private message
Display posts from previous:   
Related Topics:
Server Error (Resources) My ASP.NET app works with resources for loading text to the different controls (multilingual app) and everything works fine. but from time to time I have the following error. Then I have to wait for some time and my app continues working (I don't have to

Error while connecting remote SQL server hi all, I trying to connect remote sql server from my machine. but it giving me some errors Here are few errors listed, An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused

ODBC remote connection Hi, Iam new to programming and try to connect to an .mdb file wich is located on another machine via odbc. I need to use an UNC path format like What is the correct way to achive this. I tried the ODBC Tool under

web server connection to SQL Server - Login failed for user Cant get past the error in the subject line! I have my development machine running IIS and connecting to a database server over the network. I want to use integrated windows - so I added my anonymous user account to the database server IUSR

An existing connection was forcibly closed by the remote hos I've seen this message a lot in the groups but I haven't found a solution for it yet. Our setup is SQL Server 2000 on a Windows Server 2003 cluster. I don't believe this issue happened as often when the OS was Server 2000 but that was before I started he
Post new topic   Reply to topic    MSDOTnet.org Forum Index -> ASPNet All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group