December 01, 2020, 08:56:24 pm
News: If your question is answered please put [RESOLVED] in the subject of the initial message.
Pages: [1]   Go Down
Author Topic: Problems Connecting to SQL Server 2005 Express database from VB.NET 2005 Express  (Read 9697 times)
Jason Reed
Administrator
*

Stars: +4/-0
Offline Offline

Gender: Male
Posts: 4545

Pure Evil Administrator


WWW
« on: January 07, 2008, 09:16:54 am »

This is really annoying and stupid.

I can connect to the database using System.Data.Odbc in the .NET. The problem with this is there apparently is a small problem when dealing with stored procedures (basically they don't actually work).

So I wanted to start trying to connect using the System.Data.SqlClient part of .NET which uses more than just an DSN for the connection string. Now I can't get it to work Sad What I get is a comment that the database doesn't allow external connections (strange seeing that in fact I've got the TCP/IP connections activated and it so it can be accessed by the outside world, AND more importantly the Application is running on the same computer as the Database Server grrr)

I've even attempted to use the VB.NET 2005 Express' IDE Database Connection capabilities to connect thinking this might help. No luck I get the same error and it won't connect. Why can't I connect to this damned database server? I have tried everything I can think of but it won't connect.

The computer's name is Softyware
The SQL Server instance is mssqlserver
I'm using windows authentication (it works for the Microsoft SQL Server Management Studio Express application). I wish there was a way to get a connection string from the MSSMSE.
Logged

-- signature --

Slowhand
Supporters
*

Stars: +0/-0
Offline Offline

Gender: Male
Awards:
Topic Necromancer
Posts: 4668


I code C#!


WWW
« Reply #1 on: January 07, 2008, 09:41:35 am »

Have you checked the settings in the SQL Server Configuration Manager?
(Start>Programs>Microsoft SQL Server 2005>Configuration Tools>SQL Server Configuration Manager)
Under Protocols it lists which protocols are enabled. I've had problems connecting to SQL Servers before where these settings had changed 'magically'.

And can I see your connectionstring?
Logged


Jason Reed
Administrator
*

Stars: +4/-0
Offline Offline

Gender: Male
Posts: 4545

Pure Evil Administrator


WWW
« Reply #2 on: January 07, 2008, 10:19:19 am »

Already checked the Configuration Manager as well as the surface area wizard things are fine there.

Connection string is something like this:

Data Source=Softyware\mssqlserver;Initial Catalog=imsto;User Id=;Password=;

It should be using Windows Authentication however I've tried with sa as well and it still doesn't let me through. I've looked it up in the online help that comes with VB.NET 2005 Express and it suggests another (I think this is the third way I've seen) to connect the database. If it doesn't work then I don't know what I'm going to do as this is really ducking annoying Sad
Logged

-- signature --

Jason Reed
Administrator
*

Stars: +4/-0
Offline Offline

Gender: Male
Posts: 4545

Pure Evil Administrator


WWW
« Reply #3 on: January 07, 2008, 10:31:34 am »

Using the data source connection wizard I got this connection string

Data Source=.\MSSQLSERVER;AttachDbFilename="C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\imsto.mdf";Integrated Security=True;Connect Timeout=30;User Instance=True

And guess what?     It still didn't work grrr
Logged

-- signature --

Slowhand
Supporters
*

Stars: +0/-0
Offline Offline

Gender: Male
Awards:
Topic Necromancer
Posts: 4668


I code C#!


WWW
« Reply #4 on: January 07, 2008, 12:07:54 pm »

That connectionstring is really weird.
Have you tried this one:
"Data Source=Softyware\mssqlserver;Initial Catalog=imsto;Integrated Security=True;"
Logged


Jason Reed
Administrator
*

Stars: +4/-0
Offline Offline

Gender: Male
Posts: 4545

Pure Evil Administrator


WWW
« Reply #5 on: January 07, 2008, 12:36:14 pm »

Yep doesn't work either.

I have removed and now re-installing SQL Server Express and this time I intend on keeping the Instance name the default (.\SQLSERVER) to see if that makes any difference. I don't know why but Visual Studio 2005 Express can't find the .\MSSQLSERVER instance which is really ducking weird.

You would think that if I can connect to the database server using the SQL Server Management Studio I should be able to connect from my own application. As a matter of fact you would think that the Management Studio could help you build your ducking connection strings Sad

One would think that I'm trying to connect to a database that wasn't created by microsoft.
Logged

-- signature --

Slowhand
Supporters
*

Stars: +0/-0
Offline Offline

Gender: Male
Awards:
Topic Necromancer
Posts: 4668


I code C#!


WWW
« Reply #6 on: January 07, 2008, 01:23:51 pm »

The functionality to create connection strings from the Management Studio is something I miss too.

Btw, is it possible to connect to the database in Visual Studio by creating a data source object?
« Last Edit: January 07, 2008, 01:45:13 pm by Slowhand » Logged


Jason Reed
Administrator
*

Stars: +4/-0
Offline Offline

Gender: Male
Posts: 4545

Pure Evil Administrator


WWW
« Reply #7 on: January 07, 2008, 01:39:10 pm »

It should be but when I tried it said that I needed SQL Server Express ... Strangely enough it was already running as a service and Visual Studio didn't find it no
Logged

-- signature --

Slowhand
Supporters
*

Stars: +0/-0
Offline Offline

Gender: Male
Awards:
Topic Necromancer
Posts: 4668


I code C#!


WWW
« Reply #8 on: January 07, 2008, 01:45:33 pm »

Weird..
Logged


wrack
Master of TMEOotAP
*

Stars: +3/-0
Offline Offline

Posts: 11116


Don't look back. Look in the mirror to look back.


WWW
« Reply #9 on: January 07, 2008, 10:23:37 pm »

Ahh crud...I have faced this problem before and have successfully solved it like 2 years ago. It happened when trying out ASP.NET Starter Kit project. Surely something to do with security.

Slowhand that connection string JR posted is perfectly valid. Basically it attaches an MDB file (express database file) to the engine as oppose to make it a loaded database in the server. This way it can take the database with the application.

Let me see if I can find out my old projects and see if it has anything that might help you out.
Logged

Jason Reed
Administrator
*

Stars: +4/-0
Offline Offline

Gender: Male
Posts: 4545

Pure Evil Administrator


WWW
« Reply #10 on: January 08, 2008, 11:28:04 am »

Ok now that I've properly re-installed SQL Server Express so that the service name is now MSSQL$SQLEXPRESS Visual Studio can at least see it. The problem is that it keeps timing out and then discarding the connection Sad

I swear it is going to be easier to use an Access database and chuck SQL Server Express.
Logged

-- signature --

Slowhand
Supporters
*

Stars: +0/-0
Offline Offline

Gender: Male
Awards:
Topic Necromancer
Posts: 4668


I code C#!


WWW
« Reply #11 on: January 08, 2008, 01:57:45 pm »

Yes, but Stored Procedures in Access are a pain in the ***.
Logged


Jason Reed
Administrator
*

Stars: +4/-0
Offline Offline

Gender: Male
Posts: 4545

Pure Evil Administrator


WWW
« Reply #12 on: January 08, 2008, 02:47:41 pm »

Ok so I can connect to the database. I just can't work with the database in Visual Studio. This means that I need to create my database using the SQL Server Management Studio Express.

One would think that Microsoft would come up with a better way to integrate these two products of theirs grrr stupid mother duckers!!!
Logged

-- signature --

wrack
Master of TMEOotAP
*

Stars: +3/-0
Offline Offline

Posts: 11116


Don't look back. Look in the mirror to look back.


WWW
« Reply #13 on: January 08, 2008, 10:18:47 pm »

You can easily create database in VS.NET JR.

Lucky that there was no such thing as SQL Server Management Studio Express earlier. It was released later.
Logged

Jason Reed
Administrator
*

Stars: +4/-0
Offline Offline

Gender: Male
Posts: 4545

Pure Evil Administrator


WWW
« Reply #14 on: January 09, 2008, 05:09:59 am »

You might be able to but I can't get the Visual Studio Express to do it.
Logged

-- signature --

Pages: [1]   Go Up
Print
 
Jump to: