Reply
Connecting to SQL database via Dreamweaver
Old 04-23-2008, 05:20 PM Connecting to SQL database via Dreamweaver
Experienced Talker

Posts: 32
Hi All
I had the crazy idea of building a site using asp.net and SQL Server via Dreamweaver.!!!! To help me on my way I decided to build a tiny test site just to establish the connections. However, try as I might I can’t make a connection to a database and am now rapidly loosing the will to live due to the quite unbelievable time I have spent trying to sort this out. Now this post is my last best chance.
I am trying to connect to either of the databases that come with the freebee SQL Server package (Is it called express or something?). They are pubs and Northwind.
I am using Dreamweaver 8, XP Professional with the .Net framework v2.0
The connection string reads
"Data Source=[Computer Name]\SQLEXPRESS;
Initial Catalog=pubs;

However, I get a choice of two different error messages depending on my computer’s mood (I don’t change ANYTHING) The first is the beautifully succinct and entirely unhelpful “an unidentified error has occurred”. The second reads:

1) There is no testing server running on the server machine
2) The testing server specified for this site does not map to the http://localhost URL

despite the fact that there quite clearly is a testing server running.
After more hours trawling the net for answers, than I care to admit to I decided in desperation to try out the Dreamweaver tutorial that deals with these things (Café Townsend) to see if it offered any clues. However, when attempting to connect to the database (tutorial.mdb) I get the same two error messages, again dependent on my computer’s mood.
Ok. I could give you a blow by blow account of all the things I have tried but this post is too long already. Suffice to say that there IS a testing server running and everything maps to where it should…I am uncertain about the connection string!

Any help in the right direction would be appreciated more than you can imagine.

Cheers
Burnsie
Burnsie is offline
Reply With Quote
View Public Profile
 
Sponsored Links (We share ad revenue):
 
Old 04-24-2008, 12:59 AM Re: Connecting to SQL database via Dreamweaver
ForrestCroce's Avatar
Half Man, Half Amazing

Latest Blog Post:
North Lake Union
Posts: 2,924
Name: Forrest Croce
Location: Seattle, WA
Quote:
despite the fact that there quite clearly is a testing server running.
You have a SQL server running, but it sounds like you don't have a web server. You either need IIS, or a testbed, to run your asp.net code. You have a database server to run the SQL code, but that's not enough for a web site.

Instead of Dreamweaver, use MS's Web Dev Express. This will let you edit the markup and code, somewhat like DW, but it also comes with a test server to run your code for you.
ForrestCroce is offline
Reply With Quote
View Public Profile Visit ForrestCroce's homepage!
 
Old 04-24-2008, 04:17 AM Re: Connecting to SQL database via Dreamweaver
ooyes's Avatar
Skilled Talker

Posts: 54
Name: Web Design Company
Location: London
i dont like this MS's Web Dev Express because it doesnt have PHP support
__________________
Website design
ooyes is offline
Reply With Quote
View Public Profile Visit ooyes's homepage!
 
Old 04-24-2008, 12:52 PM Re: Connecting to SQL database via Dreamweaver
Learning Newbie's Avatar
Moderator

Latest Blog Post:
My Favorite Isaac Asimov Story
Posts: 4,093
Name: John Alexander
Sure it does. Either you can open a PHP file and edit it, or you can install PHP.NET. But if you're trying to write code against a Microsoft Internet Information Services server, that kind of goes with the territory. You can't run Windows Explorer on a Mac, either.

If you want to run ASP.NET code, you need a web server to execute that code for you. If you don't want to use Web Developer, your choices are XP Pro and Windows Server 2003.
__________________
HungarianNotation is the last resort of scoundrels. Why not the first resort? That's where it counts!
Learning Newbie is offline
Reply With Quote
View Public Profile
 
Old 04-24-2008, 01:40 PM Re: Connecting to SQL database via Dreamweaver
Experienced Talker

Posts: 32
Hi
thanks for your prompt responses, however, I will try to clarify my problem.
Oh! Before I begin… I am a bit too long in the tooth and too set in my ways to try your Web Dev Express thingimy as I have been using Dreamweaver since version 3 many years ago. I have built a couple of sites in the past using asp and Access via Dreamweaver XP but I just wanted to learn some new skills hence the desire for .net and SQL Server.
So everything above still stands.
I have followed the Dreamweaver tutorial to the letter (except where it gives the incomplete path to the database for the connection string) but still I get the message:
”an unidentified error has occurred”
This is the connection string I am using

"Provider=Microsoft.Jet.OLEDB.4.0;
DataSource=C:\ProgramFiles\Macromedia\Dreamweaver8 \Tutorial_assets\cafe_townsend\data\tutorial.mdb"

I have checked and re-checked everything but alas to no avail. This is the thing I am struggling with, the database connection.

As always any input is gratefully received.
Cheers
Burnsie
Burnsie is offline
Reply With Quote
View Public Profile
 
Old 04-24-2008, 02:39 PM Re: Connecting to SQL database via Dreamweaver
Learning Newbie's Avatar
Moderator

Latest Blog Post:
My Favorite Isaac Asimov Story
Posts: 4,093
Name: John Alexander
Quote:
Originally Posted by Burnsie View Post
I am a bit too long in the tooth and too set in my ways to try your Web Dev Express thingimy [snipt] I just wanted to learn some new skills hence the desire for .net and SQL Server.
I don't mean for this to sound insulting, but set in your ways and learning new skills are mutually exclusive. You have to give up one of these desirables or the other.

Quote:
Originally Posted by Burnsie View Post
I have followed the Dreamweaver tutorial to the letter (except where it gives the incomplete path to the database for the connection string) but still I get the message:
”an unidentified error has occurred”
This is the connection string I am using

"Provider=Microsoft.Jet.OLEDB.4.0;
DataSource=C:\ProgramFiles\Macromedia\Dreamweaver8 \Tutorial_assets\cafe_townsend\data\tutorial.mdb"

I have checked and re-checked everything but alas to no avail. This is the thing I am struggling with, the database connection.
The connection string you need should look something like this

Server=localhost; Database=Pubs; Integrated_Security=SSPI;

If you're trying to connect to a SQL Server database, the path to an Access file is irrelevant. Also if you want to connect to the database, you need credentials before the server will let you in. The cstr I wrote, above, passes through your NT credentials. I'm assuming your Windows login is allowed to use the db?

You still need your code to run, in order to build the connection into the database, as described by your connection string. Put simply, Dreamweaver won't do that for you. It's a web page editor, not a web server.
__________________
HungarianNotation is the last resort of scoundrels. Why not the first resort? That's where it counts!
Learning Newbie is offline
Reply With Quote
View Public Profile
 
Old 04-24-2008, 08:45 PM Re: Connecting to SQL database via Dreamweaver
Experienced Talker

Posts: 32
Hi
cheers again for the input. I understand that the connection string in the last post is the path to an access database. The dreamweaver tutorial uses one. I was only going through the tutorial out of sheer desperation hoping it would shed some light as to how to make a connection to a SQL Server database. However, it hasn’t (‘cause I can’t make that work either) and I now seem to have clouded the issue yet further.
I am trying to connect to the database via the Managed Data Provider for SQL Server that comes with the .NET Framework v2.0 SDK. Dreamweaver gives you a template with which to do this. This reads:

Persist Security Info=False;
Data Source=[serverName];
Initial Catalog=[databaseName];
User ID=[username];
Password=[password];

Everything is on one computer that only I use so there are no problems with authorizations (as far as I can tell). So my connection string becomes this:

Data Source=[serverName];
Initial Catalog=pubs;

I have tried adding the other line quoted above: ‘Integrated_Security=SSPI;’ previously but this had no effect. I have also tried the top line as: ‘Data Source=[serverName/ SQLEXPRESS] but this or any combination of them didn’t work.
I’ve trawled the net for solutions to “an unidentified error has occurred” (it seems I am not on my own, there are scores of links to forums etc with this as a starting point) but none helped!

Hope this is clearer
Cheers
Burnsie
Burnsie is offline
Reply With Quote
View Public Profile
 
Old 04-24-2008, 11:39 PM Re: Connecting to SQL database via Dreamweaver
ForrestCroce's Avatar
Half Man, Half Amazing

Latest Blog Post:
North Lake Union
Posts: 2,924
Name: Forrest Croce
Location: Seattle, WA
You're trying to connect to the database through .net code in the System.Data.SqlClient namespace, right?

Does Express come with SSMS, as a client tool to manage the database? It should be in your start menu under SQL Server 200x, as "SQL Server Management Studio." You can connect to the database using that, right? It's going to ask you for most of the things that need to be in a connection string for SQL Server.

Mainly, you need to grab the server name. It should be your machine name, except that from two of your posts, it looks like you're trying to access a named instance. You can install SQL Server dozens of times on the same machine, and make each one it's own, sandboxed environment. The first one doesn't get a name, and is usually called the default instance. The rest need names to distinguish. Normally you just ask for "Server=MachineName" but if you're using a named instance it has to be "Server=MachineName\InstanceName" ... the point is that if you're not using a named instance, you won't be able to connect to it using those semantics. You'd usually get a "server doesn't exist or access denied" message, though.

You need:
  • Server=X or Data Source=X
  • Credentials, which could be a username and password, or either Integrated Security=SSPI or Trusted_Connection=True
Optionally, you can ask to go directly to on of the databases the server manages, with Database=Y or Initial Catalog=Y. All of these things are synonyms; it doesn't make any difference whether you ask for db or catalog. If you don't ask for a db, you'll get the default database for that user ... which can be changed with an alter user command.

If you want to do this through .net code, you've got a number of languages at your disposal. Most people choose C# or VB, but there are plenty of others. I use C# ... everybody in most of the companies I've worked in for several years have, but I'm in Microsoft's back yard. Anyway, C# code to play with a SQL Server database looks like this:

PHP Code:
using(SqlConnection conn = new SqlConnection("Server=10.32.129.78; Database=Spam; User ID=sa; Pwd=str0ngP@ssword!")) {
   
conn.Open();

   
using(SqlCommand cmd = new SqlCommand("Select name From sys.Tables"conn)) {
      
using(SqlDataReader r cmd.ExecuteReader()) {
         if(
!= null)
            while(
r.Read())
               
Response.Write(r.GetString(0));
      }
   }

Of course, the last thing you'd ever want to do is output a list of all your tables to a client somewhere out there in web land, but ...

I don't think VB has using blocks, so you'd have to write that a little differently. Mainly with try blocks, and explicitly calling Dispose.
ForrestCroce is offline
Reply With Quote
View Public Profile Visit ForrestCroce's homepage!
 
Old 04-25-2008, 12:41 PM Re: Connecting to SQL database via Dreamweaver
Learning Newbie's Avatar
Moderator

Latest Blog Post:
My Favorite Isaac Asimov Story
Posts: 4,093
Name: John Alexander
Wow, dude, I didn't realize you knew that much about sequel?
__________________
HungarianNotation is the last resort of scoundrels. Why not the first resort? That's where it counts!
Learning Newbie is offline
Reply With Quote
View Public Profile
 
Old 04-28-2008, 06:33 PM Re: Connecting to SQL database via Dreamweaver
Experienced Talker

Posts: 32
Hi all
Whilst continuing my never ending search for an answer to my lack of database connectivity I came across an old post on some forum or other. A great many people were having a problem connecting to a database in Dreamweaver MX and the problem turned out to be a problem with Dreamweaver itself. Indeed Adobe put out a patch to deal with the problem. I downloaded this patch but when I ran it I was told that Dreamweaver 8 already had this extension. I ran it anyway but it didn’t help. I have trawled Adobe’s tech notes to see if Dreamweaver 8 has any similar known problems but couldn’t find anything.
This leaves me at a loss! Does anyone know of any problems with Dreamweaver 8 or am I stuffed?

Cheers
Burnsie
Burnsie is offline
Reply With Quote
View Public Profile
 
Old 05-01-2008, 07:16 PM Re: Connecting to SQL database via Dreamweaver
Average Talker

Posts: 15
Name: Chris
Location: UK
Post the actual connection code here and i'll give it a look.

Also, I know it may seem basic, but you need to give the user db_owner permissions on the database you are trying to connect to in MS SQL Server.
__________________
Chris
.Net C# ASP.NET Developer
Windows Systems Administrator
crashed is offline
Reply With Quote
View Public Profile
 
Old 05-01-2008, 07:44 PM Re: Connecting to SQL database via Dreamweaver
Learning Newbie's Avatar
Moderator

Latest Blog Post:
My Favorite Isaac Asimov Story
Posts: 4,093
Name: John Alexander
Quote:
Originally Posted by Burnsie View Post
Whilst continuing my never ending search for an answer to my lack of database connectivity
You've been given the answer many times already in this one thread!

Quote:
Originally Posted by Burnsie View Post
A great many people were having a problem connecting to a database in Dreamweaver MX and the problem turned out to be a problem with Dreamweaver itself.
And that's what we've been telling you!

You're trying to do something that requires 2 servers, but you're only using 1. The solution to your problem is to use a web server! As previously explained, you can use IIS which is part of Windows Server and Windows XP, or you can use the test server inside Visual Studio and Visual Web Developer Express.
__________________
HungarianNotation is the last resort of scoundrels. Why not the first resort? That's where it counts!
Learning Newbie is offline
Reply With Quote
View Public Profile
 
Old 05-01-2008, 08:09 PM Re: Connecting to SQL database via Dreamweaver
Average Talker

Posts: 15
Name: Chris
Location: UK
I didn't even read the first post correctly, apologies there.

Follow the instructions here to install IIS, then install the .Net Framework 2.0 again.

http://www.webwizguide.com/kb/asp_tu..._winXP_pro.asp
__________________
Chris
.Net C# ASP.NET Developer
Windows Systems Administrator
crashed is offline
Reply With Quote
View Public Profile
 
Old 05-03-2008, 01:02 PM Re: Connecting to SQL database via Dreamweaver
Experienced Talker

Posts: 32
Hi all
I am using IIS as a web server! I can see all pages on the testing server (localhost) but I can't connect to either the access database that comes with the Dreamweaver tutorial (cafe townsend) or either of the databases that come with SQL Server (pubs, Northwind). This is my problem!!

cheers
Burnsie
Burnsie is offline
Reply With Quote
View Public Profile
 
Old 05-04-2008, 03:15 AM Re: Connecting to SQL database via Dreamweaver
chrishirst's Avatar
Super Moderator

Posts: 10,682
Location: Blackpool. UK
open the page in a browser and see what the error really is.
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
Indifference will be the downfall of mankind, but who cares?
Code Samples | People Counting System
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 05-04-2008, 08:44 AM Re: Connecting to SQL database via Dreamweaver
Experienced Talker

Posts: 32
Hi All
When testing the database connection for the Dreamweaver tutorial (Café Townsend) I get the following message:

1) There is no testing server running on the server machine
2) The testing server specified for this site does not map to the
http://localhost/MySampleApps/_mmSer...s/MMHTTPDB.asp URL, Verify that the URL Prefix maps to the root of the site.

This is interspersed with the message: ‘an unidentified error has occurred’ for no apparent reason whatsoever!

When testing the connection for either of the SQL Server sample databases (pubs, Northwind) I get the exact same two messages with the exact same frequency. (Obviously the root folder is different from ‘MySampleApps’)

Cheers
Burnsie
Burnsie is offline
Reply With Quote
View Public Profile
 
Old 05-04-2008, 08:47 AM Re: Connecting to SQL database via Dreamweaver
Experienced Talker

Posts: 32
That should read:
//localhost/MySampleApps/_mmServerScripts/MMHTTPDB.asp

cheers
Burnsie is offline
Reply With Quote
View Public Profile
 
Old 05-05-2008,