Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0CanCan't open a connection to SQL Server
Previous
 
Next
New Post
6/21/2007 7:34 PM
 

Greetings all,

I'm working on a custom DNN module in C# that will communicate with a server running Sql Server 2005.  I cannot get it to connect to the server, however.  Essentially what happens is I create the connection (object type SqlConnection), run SqlConnection.Open on the object, and that's pretty much it.  When I check the connection state, it says it's closed.  When I run the exact same code (with the same Sql connection string) in a standalone application, it has no problem connecting to Sql Server.

I am running the most recent version of DotNetNuke.  The computer I'm using is running Windows Vista.  I should point out that Sql Server is on a different machine.

 
New Post
6/21/2007 10:37 PM
 

Put a breakpoint at the SqlConnection.Open statement and see if it ever got there.

 
New Post
6/22/2007 12:12 PM
 

Also,  I would recommend you include parts of the code with the post.  Depending on what your code looks like, it may be the way your code is working.  I work with both standalone pages and modules, using the same pattern for connecting to a database, and have never ran into any problems so it leads me to think it is a mistake in the code itself not the database connection. 

 
New Post
6/22/2007 4:02 PM
 

Nonsense, my code is perfect!

It starts out like so, simply creating an instance of the SqlHandler class that I've written.

protected void Page_Load(object sender, EventArgs e)
{
   SqlHandler sqlHandler = new SqlHandler();
   ...

The constructor for SqlHandler is where it attempts to make the connection.  _connection is a private SqlConnection.

public SqlHandler()
{
   _connection = new SqlConnection("server=(server name);Trusted_Connection=yes;database=(database name);connection timeout=1500");
try
{
   _connection.Open();
} ...

 
New Post
6/26/2007 7:14 PM
 

The problem with the connection string, I think, is Trusted_Connection=yes;.  I tried this in my own connection string and it failed to connect.  I think it should be Trusted_Connection=true;.  I am not 100% sure on this but fairly sure.  Everything else looks okay with the connection string. 

 
Previous
 
Next
HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0CanCan't open a connection to SQL Server


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out