Wrox Programmer Forums
|
BOOK: ASP.NET Website Programming Problem-Design-Solution
This is the forum to discuss the Wrox book ASP.NET Website Programming: Problem - Design - Solution, Visual Basic .NET Edition by Marco Bellinaso, Kevin Hoffman; ISBN: 9780764543869
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: ASP.NET Website Programming Problem-Design-Solution section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 9th, 2004, 09:45 AM
Friend of Wrox
 
Join Date: Jun 2004
Posts: 245
Thanks: 0
Thanked 0 Times in 0 Posts
Default ConnectionString Problem when load Solution


Help

In the README.htm it instructs me to change the server name or connection string.
I tried many different recommendation from people but still can't get this to work.
The Default.aspx.vb won't open.

I have to replace the below code:

data source=CHARUL\NetSDK;user Id=sa;password=

What does CHARUL\NetSDK mean?

What is a fool proof solution?
Is that server name, user name, workgroup name, or combination?

When I look up connection string I am given the recommendation of:
"Data Source=(local);Initial Catalog=myDatabaseName;User ID=myUsername;Password=myPassword"
data source=(local); Initial Catalog=thePhile;user Id=sa;password="


And different versions of this.

This doesn't look like:
data source=CHARUL\NetSDK;user Id=sa;password=

HELP

 
Old June 9th, 2004, 08:09 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 917
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Data Source refers to the name of the server, optionally followed by the instance name. "CHARUL\NetSDK" is for server "CHARUL" and instance name "NetSDK" (which is the default instance name of the free MSDE that comes with the Framework SDK. SQL Server doesn't need to be installed with an instance name. This is used to let you have more than 1 SQL Server on a computer. MSDE is normally installed with an instance name because Microsoft requires each MSDE installation to be isolated from each other, and from any SQL Server installs on the computer.

"(local)" is a special servername that means the local machine. This is similar to, but not equivalent, to "localhost", which is just a TCP/IP name for the local computer.

You can either use a named SQL Server username and password, or you can use Integrated security, where your Windows account will log you into SQL Server automatically.

See http://www.connectionstrings.com

Eric
 
Old June 10th, 2004, 04:14 AM
Friend of Wrox
 
Join Date: Jun 2004
Posts: 245
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I already looked at ConnectionStrings.com and it give me the exact same string:
"Data Source=(local);Initial Catalog=myDatabaseName;User ID=myUsername;Password=myPassword"

I understand that CHARUL is computer name \sql server instance name in :
data source=CHARUL\NetSDK;user Id=sa;password=

which is what I am suppose to replace, but it doesn't work.
ComputerName: COINComputer
Instance:ServerA
= COINComputer\ServerA;user Id=sa;password=;

But this doesn't work.
Help me PLEASE!

 
Old June 10th, 2004, 04:16 AM
Friend of Wrox
 
Join Date: Jun 2004
Posts: 245
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I meant:
datasource= COINComputer\ServerA;user Id=sa;password=;

Do I use = COINComputer\ServerA;user Id=sa;password=; or
"Data Source=(local);Initial Catalog=myDatabaseName;User ID=myUsername;Password=myPassword"


if there is only one instance of sql server it is called (local) so do I use "(local)" if I only have one instance of sql server?

 
Old June 10th, 2004, 08:24 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 917
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Yes, SQL Server doesn't get installed as a named instance by default (but MSDE does). You'd have to change the default installation if you wanted to give it an instance name.

Did you try this:
"Data Source=(local);Initial Catalog=myDatabaseName;User ID=myUsername;Password=myPassword"
 
Old June 11th, 2004, 03:49 AM
Friend of Wrox
 
Join Date: Jun 2004
Posts: 245
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Ques:
I heard about MSDE, what is this and how will this help the situation?
Microsoft SQL Server 2000 Desktop Engine.

I tried "Data Source=(local);Initial Catalog=myDatabaseName;User ID=myUsername;Password=myPassword"
and it is suppose to work but it doesn't.


There is no UI for MSDE so how do I restore the database file?
 
Old June 11th, 2004, 09:58 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 917
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I didn't say MSDE will help the situation, I only said that it gets installed as a named instance. As you probably know, MSDE is the free version of SQL Server. You're right that it doesn't come with Enterprise Manager (or Query Analyzer), and you can't restore a DB backup file without using Enterprise Manager.

At first it sounds like you need SQL Server to use ThePhile. However, they gave us a DB creation script so it could be run with the free osql.exe program (the ODBC commandline program that can execute SQL scripts against either MSDE or SQL Server).

But, again we run into a roadblock because the DB creation script provided with the code download is an early version that doesn't have the fixes that were made after the book was published. Only the DB backup file in the code download has all the fixes and Stored Procs.

So we're back to the requirement of having SQL Server. This isn't so bad because it's extremely difficult to work with MSDE unless you're a real expert at dealing with sql scripts.

Eric
 
Old June 14th, 2004, 08:19 PM
Registered User
 
Join Date: Jun 2004
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to uncue75 Send a message via Yahoo to uncue75
Default

Quote:
quote:Originally posted by bekim
 Ques:
I heard about MSDE, what is this and how will this help the situation?
Microsoft SQL Server 2000 Desktop Engine.

I tried "Data Source=(local);Initial Catalog=myDatabaseName;User ID=myUsername;Password=myPassword"
and it is suppose to work but it doesn't.


There is no UI for MSDE so how do I restore the database file?
I haven't been able to get the connection string resolved yet either. I did use sql 2k, so I was able to restore the database. My connection string in web.config looks like this:

Code:
    <sessionState 
            mode="InProc"
            stateConnectionString="tcpip=127.0.0.1:1039"
            sqlConnectionString="data source=(local);Initial Catalog=ThePhile;user Id=sa;password=Timebox7"
            cookieless="false" 
            timeout="20" 
    />
port 1039 because that's what sql2k uses instead of 1433

also there are other connection strings under the config directory. Several files in there have connection strings. Mine look like this:

Code:
<ConnectionString>server=(local);database=ThePhile;uid=sa;pwd=;</ConnectionString>
I was able to open the studio solution file. I am using vs.net 2003 enterprise architect. It asked if I wanted to convert the solution to the new vs.net format. (hope that is helpful to you bekim)


I am completely at a loss for my connection string problem. the error that I am getting is:

Error

--------------------------------------------------------------------------------
An unexpected error has occurred on this page.The system administrators have been notified.

The error occurred in:
http://localhost/thephilevb/Default.aspx

Error Message:
SQL Server does not exist or access denied.

Error Stack:
System.Data.SqlClient.SqlException: SQL Server does not exist or access denied.
   at System.Data.SqlClient.ConnectionPool.GetConnection (Boolean& isInTransaction)
   at System.Data.SqlClient.SqlConnectionPoolManager.Get PooledConnection(SqlConnectionString options, Boolean& isInTransaction)
   at System.Data.SqlClient.SqlConnection.Open()
   at Wrox.WebModules.Data.DbObject.RunProcedure(String storedProcName, IDataParameter[] parameters, Int32& rowsAffected) in C:\wrox\ThePhileVB\WebModules\Core\DBObject.vb:lin e 53
   at Wrox.WebModules.Polls.Data.Questions.GetCurrentId( ) in C:\wrox\ThePhileVB\WebModules\Polls\Polls.Data\Que stions.vb:line 158
   at Wrox.WebModules.Polls.Business.Question.GetCurrent Id() in C:\wrox\ThePhileVB\WebModules\Polls\Polls.Business \Question.vb:line 227
   at Wrox.WebModules.Polls.Web.Controls.User.Poll.DataB ind() in C:\wrox\ThePhileVB\WebModules\Polls\Poll.ascx.vb:l ine 260
   at Wrox.WebModules.Polls.Web.Controls.User.Poll.Page_ Load(Object sender, EventArgs e) in C:\wrox\ThePhileVB\WebModules\Polls\Poll.ascx.vb:l ine 62
   at System.Web.UI.Control.OnLoad(EventArgs e)
   at System.Web.UI.Control.LoadRecursive()
   at System.Web.UI.Control.LoadRecursive()
   at System.Web.UI.Control.LoadRecursive()
   at System.Web.UI.Page.ProcessRequestMain()


I can telnet to localhost 1039. I reset my sa password. I've logged into query analyzer using the credentials in my connection string. What else can I do?

thanks for any help you can offer! I really like this framework if I can get it to work. I am comming from a fusebox (www.fusebox.org) framework/methodology, which is a lot like this, so if I can get this working I will be one happy man.


David
 
Old June 14th, 2004, 10:12 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 917
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Your connection string doesn't belong in the Session State section of web.config. It only goes in the various .config files in the config subdir. I don't think ThePhile uses session state as it exists now (unless I missed something).

I'm guessing the SQL Connection string you specified in web.config might work if you move it to the other .config files. Every .config file needs a connection string.

You really should test your connection string with a simple Console app just to make sure you have it right. Once you know it works, then plug it in to your .config files.

Create a new C# Console Project, and paste this text in (bear with me if you're a VB developer - this is just a test of your connection string):

using System;
using System.Data;
using System.Data.SqlClient;

namespace MyTest
{
  class MainApp
  {
    static void Main(string[] args)
    {
      string ConnectStr = "Data Source=(local);Initial Catalog=ThePhile;User id=sa;Password=xxxx;";
      string SqlQuery = "select FirstName, LastName from accounts_users";

      SqlConnection Connection = new SqlConnection(ConnectStr);
      SqlCommand Command = Connection.CreateCommand();
      Command.CommandText = SqlQuery;
      Connection.Open();
      SqlDataReader Reader = Command.ExecuteReader();

      while (Reader.Read())
      {
        Console.WriteLine( "{0}\t{1}", Reader.GetString(1), Reader.GetString(2));
      }

      Reader.Close();
      Connection.Close();

      Console.Write("Press Enter ...");
      Console.Read();
    }
  }
}

Experiment with your connection string until it works. When it works, paste it into the .config files in the config subdir of ThePhile. This is Accounts.Config:

<?xml version="1.0" ?>
<ModuleSettings xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<ConnectionString>server=(local);database=ThePhile ;uid=sa;pwd=xxxx;</ConnectionString>
</ModuleSettings>

Eric
 
Old June 16th, 2004, 12:08 AM
Registered User
 
Join Date: Jun 2004
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to uncue75 Send a message via Yahoo to uncue75
Default

Quote:
quote:Originally posted by englere
 Your connection string doesn't belong in the Session State section of web.config. It only goes in the various .config files in the config subdir. I don't think ThePhile uses session state as it exists now (unless I missed something).

I'm guessing the SQL Connection string you specified in web.config might work if you move it to the other .config files. Every .config file needs a connection string.

You really should test your connection string with a simple Console app just to make sure you have it right. Once you know it works, then plug it in to your .config files.

Create a new C# Console Project, and paste this text in (bear with me if you're a VB developer - this is just a test of your connection string):
Eric
Eric, thank you so much for taking the time to help me. I worked on making connections to my sql server on my laptop today, but nothing ever worked. I always got the error: sql server doesn't exist or access was denied. I tried your console app and got an error as well. I changed the connectionstring many times (using examples at connectionstrings.com), but was still unsuccessful. again thank you for your help.

I am at the point of reinstalling sql. I changed all the sercurity, rights, and user options I could think of. there's nothing on it, it's just my copy for development on my laptop.

Hopefully this will fix my problem. I have been pulling my hair out since late monday night. It's really weird because enterprise manager and sql query analyzer both work. I can't create a connection in vs.net or create data source in xp either.

As I was typing this, I figured it out. I forgot I am using "SQL Server Developer Edition". It appears that it uses port 1039 instead of 1433. I had to change all my data sources to "server=localhost, 1039;etc.." and that got me past the sql server errors that I was getting.

thanks!

David







Similar Threads
Thread Thread Starter Forum Replies Last Post
VBScript or SQL solution to problem mat41 Classic ASP Professional 5 October 8th, 2008 05:13 PM
A serious string problem. Urgent solution needed. asfak XSLT 2 November 28th, 2007 06:08 AM
Windows based Problem Design Solution Book ricpue BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 5 September 1st, 2006 07:47 AM
php/mysql programming problem - design - solution jben.net Beginning PHP 8 November 14th, 2003 09:00 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.