TechTalkz.com Logo

Go Back   TechTalkz.com Technology & Computer Troubleshooting Forums > Tech Support Archives > Programing Languages > C#(C Sharp)

Notices

Reply
 
Thread Tools Display Modes
Old 05-09-2007, 03:30 PM   #1
Todd Jaspers
Guest
 
Posts: n/a
RE: Unable to connect to SQL remotely through SqlConnection???


Thanks Peter, I appreciate this. I'll try this now.


"Peter Bromberg [C# MVP]" wrote:

> Todd, "No error" is kind of a blanket statment. Have you tried something like
> this?
>
> SqlConnection sqlConn2 = null;
> try
> {
> sqlConn2 = new SqlConnection("Data Source=database_name;
> connection timeout=30");
> }
>
> catch(SqlException sqlex)
> {
> System.Diagnostics.Debug.WriteLine(ex.Message +);
> }
>
> finally
> {
> sqlConn2.Close();
> }
>
> I bet you will see something in the output window in debug mode. Get in the
> habit of wiring up your code with exception handling; it will save you a lot
> of time.
> -- Peter
> Recursion: see Recursion
> site: http://www.eggheadcafe.com
> unBlog: http://petesbloggerama.blogspot.com
> BlogMetaFinder: http://www.blogmetafinder.com
>
>
>
> "Todd Jaspers" wrote:
>
> > Hey guys,
> >
> > I've written a web application that I'm simply trying to use to
> > access a database. When I run the application locally (or as an NT Service)
> > it can easily access the remote SQL database. However, when I host the item
> > as a web application, it can ONLY access local SQL databases on that server,
> > and NOT remote SQL databases (even if it's on our network). Like I said, I
> > can access those same databases when I run the program in localhost, but NOT
> > when it's hosted.
> >
> > What could the problem possibly be? I don't get any errors, it just doesn't
> > pull up any data.
> >
> > This are the connection strings that I've tried, neither of which work. I've
> > created a local ODBC connection to the database, and the ODBC connection has
> > no problem connecting to the server with the SQL database on it, but it just
> > doesn't work when I'm accessing it remotely. I don't get any errors, there
> > just isn't any data.
> >
> > For obvious reasons, I've changed the info below.
> >
> >
> > Any help you guys can give me, I'd really appreciate it!!!
> >
> >
> > THanks!!!
> >
> >
> >
> > // SqlConnection sqlConn2 = new SqlConnection("user id=XXXXXX" +
> > // "password=XXXXXX;server=SERVERNAME;" +
> > // "Trusted_Connection=yes;" +
> > // "database=database_name; " +
> > // "connection timeout=30");
> >
> > SqlConnection sqlConn2 = new SqlConnection("Data Source=database_name;
> > connection timeout=30");
> >

  Reply With Quote
Old 05-09-2007, 03:30 PM   #2
Peter Bromberg [C# MVP]
Guest
 
Posts: n/a
RE: Unable to connect to SQL remotely through SqlConnection???

Todd, "No error" is kind of a blanket statment. Have you tried something like
this?

SqlConnection sqlConn2 = null;
try
{
sqlConn2 = new SqlConnection("Data Source=database_name;
connection timeout=30");
}

catch(SqlException sqlex)
{
System.Diagnostics.Debug.WriteLine(ex.Message +);
}

finally
{
sqlConn2.Close();
}

I bet you will see something in the output window in debug mode. Get in the
habit of wiring up your code with exception handling; it will save you a lot
of time.
-- Peter
Recursion: see Recursion
site: http://www.eggheadcafe.com
unBlog: http://petesbloggerama.blogspot.com
BlogMetaFinder: http://www.blogmetafinder.com



"Todd Jaspers" wrote:

> Hey guys,
>
> I've written a web application that I'm simply trying to use to
> access a database. When I run the application locally (or as an NT Service)
> it can easily access the remote SQL database. However, when I host the item
> as a web application, it can ONLY access local SQL databases on that server,
> and NOT remote SQL databases (even if it's on our network). Like I said, I
> can access those same databases when I run the program in localhost, but NOT
> when it's hosted.
>
> What could the problem possibly be? I don't get any errors, it just doesn't
> pull up any data.
>
> This are the connection strings that I've tried, neither of which work. I've
> created a local ODBC connection to the database, and the ODBC connection has
> no problem connecting to the server with the SQL database on it, but it just
> doesn't work when I'm accessing it remotely. I don't get any errors, there
> just isn't any data.
>
> For obvious reasons, I've changed the info below.
>
>
> Any help you guys can give me, I'd really appreciate it!!!
>
>
> THanks!!!
>
>
>
> // SqlConnection sqlConn2 = new SqlConnection("user id=XXXXXX" +
> // "password=XXXXXX;server=SERVERNAME;" +
> // "Trusted_Connection=yes;" +
> // "database=database_name; " +
> // "connection timeout=30");
>
> SqlConnection sqlConn2 = new SqlConnection("Data Source=database_name;
> connection timeout=30");
>

  Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: Unable to connect to SQL remotely through SqlConnection??? Todd Jaspers C#(C Sharp) 1 05-09-2007 03:30 PM
Re: Unable to connect to SQL remotely through SqlConnection??? Ignacio Machin \( .NET/ C# MVP \) C#(C Sharp) 1 05-09-2007 03:30 PM
unable to connect to Updates bobby02169 Microsoft Office 10 28-08-2007 03:47 PM
Unable to connect to RAS RAS Help Needed Windows Server 2003 0 28-08-2007 05:50 AM
Unable to connect to RAS RAS Help Needed Windows Server 2003 0 28-08-2007 05:49 AM



New To Site? Need Help?

All times are GMT +5.5. The time now is 08:03 PM.


vBulletin, Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO
Copyright © 2005-2009, TechTalkz.com. All Rights Reserved - Privacy Policy
Valid XHTML 1.0 Transitional