Showing posts with label web. Show all posts
Showing posts with label web. Show all posts

Sunday, March 25, 2012

Cant find SQL Server

I have the following in my web.config

<appSettings>
<add key="strConn" value="server=10.100.1.2;uid=sa;pwd=;database=MyDB/>
</appSettings
and I am getting the following error message --

"SQL Server cannot be found or access denied"

if I replace the server IP address with server name, it works fine.

Am I missing something here? Help!

Thanks

Bugme

See the linkhttp://blogs.msdn.com/sql_protocols/archive/2005/10/29/486861.aspx has some information. Hope that helps you!

My guess is name resolution faild!

Tuesday, March 20, 2012

Can't even create a new SQL db, despite SQL Server 2005 installed.

I've just installed Visual Web Developer Express and SQL Server 2005. I'm running thru the painfully slow video tutorials from Microsoft (see here).

I've open Web Dev and tried to create a new SQL Database Item, only to receive this error:

"Connections to SQL Server files (*.mdf) require SQL Server Express 2005 to function properly. Please verify the installation of the component or download from the URL http://microsoft.com"

I'm totally new to this, but this still makes no sense.

hi Brad,

only SQLExpress is designed to use User Instances, the feature you are supposed to use via all "Express editions" of Visual Studio ..

as you can see, all other SQL Server 2005 editions do not provide this feature so you have to directly code your connection to access these editions, as the builtin designers of Express editions of VS do not grant the possibility to connect to traditionals instances..

or... you can install a SQLExpress instance side by side on your pc..

regards

Monday, March 19, 2012

Cant drill through from one report to another with report viewer

Hello all,

this is my first post to asp.net!

I am having a problem getting a drill through to work in the web report viewer. In report1 i have a table with groups and on the key field i want to drill down through i right click >properties> navigation and select jump to report. From there I select the predesigned report2 from the list and add the appropriate parameters.

It works fine when i test it in the dev enviroment and when i deploy it to the report server it works fine there. but when I debug and run it through the website itself and go to the report then click on the hyperlink it goes to a "page cannot be displayed' page.

I have been working on this for 2 days googling the heck out of it and testing several scenarios, but to no avail. I'm sure its something stupidly simple.

has anyone else had this problem?

Help!

thanks so much!

HI,CodeSquirrelMonkey:

Make sure you have put the target report in the right place which is defined in the drill through setting.

Second, you can have a try to open the target report directly on the website.

If i misunderstand you about your question, please feel free to correct me and i will try to help you with more information.

I hope the above information will be helpful. If you have any issues or concerns, please let me know. It's my pleasure to be of assistance

|||

Hi Rex,

Thanks for the response. I did make sure that the drill through report is in the right place and it didnt work on the live site either.

I did get around the problem though. I created an fresh new aspx page and dropped a fresh report viewer on it and tried it again and it works fine now. I did a comparison of the two pages' code and couldnt find anything obvious that could have caused it. It does work fine now.

the only other thing was to make sure that the page_load has an if not ispostback on it so that it would refresh and drilldown properly.

Thanks again

Craig

Sunday, March 11, 2012

Can't deliver reports in Web Archive format

I can't deliver reports in web archive format using subscriptions.
If I choose to send only the link it's working.
I used to have SP1 for Reporting Services but I was forced to unintall it
because I am using Romanian lang for my reports and all reports with date
fields where not working when I try to export them to PDF.
Any ideas ?
Sorin Sandu
RomaniaI forgot my error
"Failure sending mail: An error has occurred during report processing" on
the subscriptions page.
"spp" <spp@.nospam.nospam> a scris în mesajul de
ºtiri:%23mJdsxpOFHA.3072@.TK2MSFTNGP09.phx.gbl...
>I can't deliver reports in web archive format using subscriptions.
> If I choose to send only the link it's working.
> I used to have SP1 for Reporting Services but I was forced to unintall it
> because I am using Romanian lang for my reports and all reports with date
> fields where not working when I try to export them to PDF.
> Any ideas ?
> Sorin Sandu
> Romania
>|||I'm having the same problem - is there a log file somewhere I can check? I
checked event viewer, and also looked at the reportserver's tables in SQL but
I didn't find anything around the time of my test email
"spp" wrote:
> I forgot my error
> "Failure sending mail: An error has occurred during report processing" on
> the subscriptions page.
> "spp" <spp@.nospam.nospam> a scris în mesajul de
> ºtiri:%23mJdsxpOFHA.3072@.TK2MSFTNGP09.phx.gbl...
> >I can't deliver reports in web archive format using subscriptions.
> > If I choose to send only the link it's working.
> > I used to have SP1 for Reporting Services but I was forced to unintall it
> > because I am using Romanian lang for my reports and all reports with date
> > fields where not working when I try to export them to PDF.
> > Any ideas ?
> > Sorin Sandu
> > Romania
> >
>
>

Can't delete Web Assistant task

I used the Web Assistant tool to monitor a couple of tables. When I was fin
ished with the monitoring after a couple of weeks, I didn't want to monitor
the tables anymore. I deleted the proceedure, and now when I add data to th
e tables, I get an error me
ssage:
Failed@.CDBBaseGroupObj::dbwrite attribute xref.Database error:[Microsoft][ODBC SQL Serv
er Driver][SQL Server] SQL Web Assistant: Could not execute the SQL statemen
t.
I click "OK" on the error message and proceed as normal.
Can anyone point me in the right direction of getting rid of this error mess
age popping up?
thanks,
SKClarkWhen you select the option to monitor tables in the Web Assistant, it
also creates triggers. If all you did was manually drop the stored
procedure, then the triggers likley still exist. At this point you'll
need to delete them manually. In future, use sp_dropwebtask, which
will clean up all of the objects.
-- Mary
MCW Technologies
http://www.mcwtech.com
On Tue, 10 Feb 2004 08:51:08 -0800, "SKClark"
<anonymous@.discussions.microsoft.com> wrote:

>I used the Web Assistant tool to monitor a couple of tables. When I was finished w
ith the monitoring after a couple of weeks, I didn't want to monitor the tables anym
ore. I deleted the proceedure, and now when I add data to the tables, I get an erro
r m
essage:
>Failed@.CDBBaseGroupObj::dbwrite attribute xref.Database error:[Microsoft][ODBC SQL Ser
ver Driver][SQL Server] SQL Web Assistant: Could not execute the SQL stateme
nt.
>I click "OK" on the error message and proceed as normal.
>Can anyone point me in the right direction of getting rid of this error mes
sage popping up?
>thanks,
>SKClark|||cool...I found 3 triggers attached to a table. I deleted them and now the
error message doesn't show up anymore.
Thanks for your help!!! :-)
-- Mary Chipman wrote: --
When you select the option to monitor tables in the Web Assistant, it
also creates triggers. If all you did was manually drop the stored
procedure, then the triggers likley still exist. At this point you'll
need to delete them manually. In future, use sp_dropwebtask, which
will clean up all of the objects.
-- Mary
MCW Technologies
http://www.mcwtech.com
On Tue, 10 Feb 2004 08:51:08 -0800, "SKClark"
<anonymous@.discussions.microsoft.com> wrote:

>I used the Web Assistant tool to monitor a couple of tables. When I was finished w
ith the monitoring after a couple of weeks, I didn't want to monitor the tables anym
ore. I deleted the proceedure, and now when I add data to the tables, I get an er[/
color]
ror message:
>thanks,
>SKClark

Wednesday, March 7, 2012

Cant create new database / CREATE DATABASE permission denied in database master (error 262

I am using SQL express and Visual web developer on windows Vista.

When I try to create a new database the following message appears.

CREATE DATABASE permission denied in database master (error 262)

I log on to my computer as an administrator.

Help appreciated

Prontonet

How do you login to sql server? Do you use sql authentication? If so, check the account you login with has appropriate permissions. Or are you using windows authentication?

|||

Can you login to database engine and read data anyway??

You need "CREATE DATABASE" permission to create new database. However, to make things easier, i would suggest you use sys_admin permission over your database.Open sql express and click "security"-->Logins, see if your login name is listed there. Rigth click your user name and select "properties", click "server roles" or "User Mappings" to see which role has been assigned to your account. If you are not a sys_admin/db_owner role, login agin using a dbo account(if you have one) and assign you account a sys_admin/dbo permission.

Hope my suggestion helps

Cant Create MSDE Database using ASP.NET Matrix

Hi i am having problems creating a new MSDE database when using the
ASP.NET Web Matrix to create it.
It says to click on New Connection, select SQL Sever Authentication,
add in the username and password and then click create new database.
I get an error though saying
Unable to connect to database server
SQL Server does not exist or access denied
ConnectionOpen(Connect())
Any suggestions?
Perhaps you didn=B4t setup the right network settigns:
http://www.codeproject.com/database/ConfigureMSDE.asp
HTH, Jens Suessmeyer.
|||Nope still doesnt seem to be letting me create a new database through
the ASP.Net Matrix.
I removed and then reinstalled the MSDE following the link you gave me,
then set it up following their stages.
I can create a database through the cmd.exe but still having the
problems with ASP.Net Matrix.
Going to remove and reinstall the .net matrix and see if that works.
|||Hi there, managed to get everything working now. deleted the .net web
matrix and the MSDE off my computer. then reinstalled everything again.
the version of .net web matrix i had seemed to be out of date so maybe
this is what was causing the problem.
Thanks for your help.

Saturday, February 25, 2012

Cant copy database, strange error

I'm trying to copy a database from my web host to local Sql Server 2005 instance using the Copy Database wizard. I get this error:

An exception occurred while executing a Transact-SQL statement or batch.

Server user 'celestine' is not a valid user id database 'db2'.

However, 'db2' isn't the database I was trying to copy! I am trying to copy db1, but this error is complaining about db2, which is in fact somebody else's database that I don't have a login for. Why am I getting an error about db2 when I'm not trying to do anything with db2?

I can however export the tables from db1 just fine using Export. But then I have to go back and generate script to re-create the stored procs, views, etc., so it is rather tedious to do it that way.

This may be possible. For example if there is a view in db1 which references a table in db2, and the celestine login does not have access to db2, you may encounter this error.

So to avoid such issue, you can move/copy database by taking a full backup of the source database and then restore it on the destination server.

|||

Good idea but -- No, this is not the case. This is a shared hosting situation, the 2nd database is owned by someone else, I have absolutely no access to it at all. There is no relationship whatsoever between the databases.

I can't do a backup/restore either because I don't have access to the remote filesystem.

|||

Urgh...that's really a trouble. Then check whether your login has sufficient permissions to perform copy database task:

Required permissions

For the Copy Database Wizard to work, you must have the correct permissions, depending on how you are copying the database, as follows:

For the Detach and Attach Method, you must be a member of thesysadmin fixed server role on the both source and destination servers.

|||Right. But a) I do have correct permissions for both source/destination for the database I'm trying to copy, and b) The error is not pertaining to the database I want to copy. The error mentions a different database, that I have zero permissions for, that I will never have permissions for, that I don't want permissions for. I am trying to copy db1 and the error says "you don't have permissions for db2". Why is it even checking anything for db2?

Cant convert types

I ham trying to convert a 'System.Data.CommandType' to 'System.Web.UI.WebControls.SqlDataSourceCommandType'.

but I get

Error 4 Cannot implicitly convert type 'System.Data.CommandType' to 'System.Web.UI.WebControls.SqlDataSourceCommandType'. An explicit conversion exists (are you missing a cast?) D:\Inetpub\wwwroot\Help_Desk\App_Code\HelpDeskSql.cs 99 42 http://localhost/Help_Desk/

My problem is I cant seem to get a explicit conversion to work. if it cast it I get an.

Specified argument was out of the range of valid values.
Parameter name: value
. when running the page. but no build errors, does anyone know how to cast this?

Show us your exact code or markup that you're talking about, which is giving you the error.|||

if (cmdUpdate !=null)

{

HDS.UpdateCommand = cmdUpdate.CommandText;

HDS.UpdateCommandType = (SqlDataSourceCommandType)cmdUpdate.CommandType; //errror line

for (int i = 0; i < cmdUpdate.Parameters.Count; i++)

{

HDS.UpdateParameters.Add(cmdUpdate.Parameters[i].ParameterName, cmdUpdate.Parameters[i].Value.ToString());

}

}

Can't connection to SQL 2000 on Windows 2003 from web application running on windows x

I'm developing a web application that is running locally on my Windows XP PC
. It connects to remote database server which sits on a Windows 2003 server.
When i try to open the connection, i recieve an error, "SQL Server does not
exist or access denied". I
know for fact this connection string works, because I can use the same conne
ction string in a console application, and retrieve data. So far I have esta
blished the following:
-- I can connect to the DB via all client applications (query analyzer, .net
console appliation etc.), except from .net web application.
-- Other developers running windows 2003 and II6 can connect to DB using the
same configuration.
-- Developers, like myself, running on XP and IIS 5.1 can NOT connect.
-- from the .net web application I can connect to SQL servers that reside on
Windows 2000 server.
thanksThanks for posting what you've tried:
This helps enormously. <g>
-- I can connect to the DB via all client applications (query analyzer,
.net console appliation etc.), except from .net web application.
-- Other developers running windows 2003 and II6 can connect to DB using
the same configuration.
-- Developers, like myself, running on XP and IIS 5.1 can NOT connect.
-- from the .net web application I can connect to SQL servers that reside
on Windows 2000 serv
So, what's missing here is what security context or that your web
application is using and what security mode
IIS is in.
Are you running the IIS site in Annony, Basic or Windows Auth ?
Are you attempting to connect to SQL from IIS using an account with
username & password or
with a Trusted Connection?
Does the .NET app attempt to Impersonate?
Thanks,
Kevin McDonnell
Microsoft Corporation
This posting is provided AS IS with no warranties, and confers no rights.|||Kevin,
thank you for the reply. The settings on the IIS and the web application are
fairly generic, I believe I'm using all the default values for configuratio
n.

>Are you running the IIS site in Annony, Basic or Windows Auth ?
Annonymous access is enable on the IIS.

>Are you attempting to connect to SQL from IIS using an account with
username & password or with a Trusted Connection?
I'm using an SQL account with username and password to connect to the DB

>Does the .NET app attempt to Impersonate?
there is no impersonation involved.
-- Kevin McDonnell [MSFT] wrote: --
Thanks for posting what you've tried:
This helps enormously. <g>
-- I can connect to the DB via all client applications (query analyzer,
.net console appliation etc.), except from .net web application.
-- Other developers running windows 2003 and II6 can connect to DB using
the same configuration.
-- Developers, like myself, running on XP and IIS 5.1 can NOT connect.
-- from the .net web application I can connect to SQL servers that reside
on Windows 2000 serv
So, what's missing here is what security context or that your web
application is using and what security mode
IIS is in.
Are you running the IIS site in Annony, Basic or Windows Auth ?
Are you attempting to connect to SQL from IIS using an account with
username & password or
with a Trusted Connection?
Does the .NET app attempt to Impersonate?
Thanks,
Kevin McDonnell
Microsoft Corporation
This posting is provided AS IS with no warranties, and confers no rights.|||it turns out, to resolve the issue, we just needed to install sp3 a couple o
f times on the SQL server.|||Hi,
I'm having the same problem. And these are mine settings:
Q: Are you running the IIS site in Annony, Basic or Windows Auth ?
A: I'm using FORMS-authentification (web.config)
Q: Are you attempting to connect to SQL from IIS using an account with usern
ame & password or with a Trusted Connection?
A: I want to connect throug username and password
Q: Does the .NET app attempt to Impersonate?
A: As far as i know i don't.
I hope u can explain me the problem.
Thanx Bram
Posted using Wimdows.net NntpNews Component -
Post Made from http://www.SqlJunkies.com/newsgroups Our newsgroup engine sup
ports Post Alerts, Ratings, and Searching.

Friday, February 24, 2012

Cant connect Web Server to SQl Server

I have a web server with Advanced server 2003 on it and its name is WEB that is trying to get data off of the SQL 2000 server (SQL). They are only on a local area network right now because we are just testing before we put them into production. They used to be on the same machine so linking them was never a problem. I've created a ODBC connection from the web to the sql and named it "SQL". The Databae that i'm trying to access is Dept_Data. This is the same code we had for the old connection i just changed the source name to SQL.

<%
Dim MM_connDept_Data_STRING
MM_connDept_Data_STRING = "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=Dept_Data;Data Source=SQL"
%>

I've messed around with this for the past two days and can't figure it out, i'm not all that familar with it but i hope someone can help me out. I kind of think it is a permissions or a login issue. Is this enough info. Help!Try...

"DRIVER=SQL Server;SERVER=SQL;Database=dept_data;UID=userlogon ;PWD=userpassword"|||What logon and password is it the one to get into the Database or the what?|||Logon and Pwd for the Database.|||when put the login and password in it asks me to log into the web server for some reason. The code that we put in is in an asp file that is included in the asp file that we want displayed. Do we need to configure an anounomous account?|||The WEB site has to allow anonymous access. That's set by right-clicking the site in IIS Manager, selecting security, and checking the Allow Anonymous Access box. Also make sure you have installed the SQL Server Client Network Utilities on the WEB Server. In the string I gave you, where it says

SERVER=SQL;

I assume SQL is the name of the SQL server box.|||Is this what i need to download on my advanced server 2003 web machine? http://www.microsoft.com/downloads/details.aspx?FamilyID=9032F608-160A-4537-A2B6-4CB265B80766&displaylang=en
And yes the 2000 sql server is named SQL.|||Part of the installation of SQL Server 2000 asks what you want to install. You have a choice of installing the server of just the client side stuff. Run the install on your WEB server and pick the client tools from the menu.

Sunday, February 19, 2012

cant connect to sql server 2005 from my asp.net application

Hi

I can't connect to sql server 2005 from my asp.net web page. I seem to be able to connect to it when i run the application from within visual studio but i can't connect to it when i run the application from IIS.

I am new to sql server 2005 express so please bear with me.

The error message i get is:

Cannot open database "Vets" requested by the login. The login failed.
Login failed for user 'OSCAR2K4\ASPNET'.

I don't know where this user OSCAR2K4\ASPNET came from but i looked in sql server 2005 and there he is. In the left hand pane I went to Security and then logins and found oscar2k4\asp.net there. I went to the properties for this user and went to User Mappings. There was no tick next to my Vets database so I added one and ran the application from IIS. I also added the user to every single role in the vets database (including dbowner). I also went into the vets database itself and found the oscar/aspnet user and made sure he was added to every role.

I ran the application again. This time i got a lots of different errors. If the page was trying to run a select procedure I got the error user does not have select permission. If the page was running an SP i got the error or user does not execute permission


I have never had this problem before so I don't understand.

Where did this user come from? Was he created automatically when i configured my database for membership and roles? How do i set up this user so he can access the databsae from IIS.

The only way I could get the application to run from IIS was to go to Security - Logins for sql server and add the oscar2k4\asp.net user to the sysadmin role.

I find this very strange. Naturally i don't want to leave oscar2k4 in sysadmin.

Please help :) I can't upload my website until i fix this

Thanks, andrea

<server>\ASPNET is 'ASP.NET Machine Account', one of the access control lists (ACLs) that are set by default on the Machine.config file and the root Web.config file.

What's the OS version (e.g. Window2000 or Xp) of the box? You can take a look at this articlehttp://msdn2.microsoft.com/en-us/library/ab4e6cky.aspx

Thursday, February 16, 2012

Cant connect to SQL server

I have a SQL server hosting version 2005 and support ASP.net 2.0. Evrerything works just fine with other databases. However when I use Web Configure supported in Visual Studion 2005 to define the membership and user control and upload all files and folders to the server. It never works. I says can not connect to SQL server. The help guy from my hosting says it does not support SQL express and they do not support that.

By default the database connection string is configured by SQL express and I do not know how to change it.

Not all, it is said that just upload everything to the server and that's all but it is not that. To work with database I had to use SQL server 2005 to upload the database by using import wizard and import tables into the database folder in my server. Do I need to do them same with membership and role database? I tried but it still says error .

I am just beginer so need help form you, the masters.

The URL show error is www.tinhtran.com/Default.aspx

thanks

Hi,

take a look at this site for connectionstrings. Personally, I find it strange that you don't get the correct connectionstring from the helpdesk.

Grz, Kris.

Can''t connect to SQL Express or SQL 2005 from C# web app and IIS

Hi all,

I'm new to this forum and haven't worked with SQL Server for a couple of years. Now it seems I'm getting back into it. I have SQL Express and SQL 2005 installed on an XP sp2 machine with IIS 5.1. I have a C#/ASP.NET web app in Visual Studio 2005 that keeps getting an error on attempting to connect (SqlConnection object). It's a generic error saying a probable cause is SQL Express default setup not allowing remote connections. Remote connections are turned on for both TCP and UDP. I can connect from within a small C# windows application using the same uid and pwd, so I suspect it's something related to IIS talking to SQLExpress. I would appreciate any help on other things to check. I am also fairly new to using IIS in the development environment.

Thanks

It could be because you didn't specify the instance name when you tried to connect from the C# app? It could also be that SQLBrowser isn't running.

Hope that helps,

John

|||

This is because SQL Server 2005 Express Edition does not accepts remote connections by default:

How to: Enable Network Access During Installation of SQL Server 2005 Express Edition

|||

Thanks John,

Yes, I specified the instance name and verified SQLBrowser is running. COnnection string = "Server=BUTTERFLY\SQLExpress; Initial Catalog=catalog; uid=username; pwd=password;

|||

Ronald,

Thanks for pointing me to this information. It didn't actually solve my dilemma, but it did get the juices flowing. This is related to a project I inherited and upgraded from .NET 1.1 to 2.0. The sql connection string referenced a property for "server=", changing this to "data source=" allowed the connection to open properly. I am reading the links you pointed and they are very helpful. Thanks

Can''t connect to SQL Express or SQL 2005 from C# web app and IIS

Hi all,

I'm new to this forum and haven't worked with SQL Server for a couple of years. Now it seems I'm getting back into it. I have SQL Express and SQL 2005 installed on an XP sp2 machine with IIS 5.1. I have a C#/ASP.NET web app in Visual Studio 2005 that keeps getting an error on attempting to connect (SqlConnection object). It's a generic error saying a probable cause is SQL Express default setup not allowing remote connections. Remote connections are turned on for both TCP and UDP. I can connect from within a small C# windows application using the same uid and pwd, so I suspect it's something related to IIS talking to SQLExpress. I would appreciate any help on other things to check. I am also fairly new to using IIS in the development environment.

Thanks

It could be because you didn't specify the instance name when you tried to connect from the C# app? It could also be that SQLBrowser isn't running.

Hope that helps,

John

|||

This is because SQL Server 2005 Express Edition does not accepts remote connections by default:

How to: Enable Network Access During Installation of SQL Server 2005 Express Edition

|||

Thanks John,

Yes, I specified the instance name and verified SQLBrowser is running. COnnection string = "Server=BUTTERFLY\SQLExpress; Initial Catalog=catalog; uid=username; pwd=password;

|||

Ronald,

Thanks for pointing me to this information. It didn't actually solve my dilemma, but it did get the juices flowing. This is related to a project I inherited and upgraded from .NET 1.1 to 2.0. The sql connection string referenced a property for "server=", changing this to "data source=" allowed the connection to open properly. I am reading the links you pointed and they are very helpful. Thanks

Can''t connect to SQL Express or SQL 2005 from C# web app and IIS

Hi all,

I'm new to this forum and haven't worked with SQL Server for a couple of years. Now it seems I'm getting back into it. I have SQL Express and SQL 2005 installed on an XP sp2 machine with IIS 5.1. I have a C#/ASP.NET web app in Visual Studio 2005 that keeps getting an error on attempting to connect (SqlConnection object). It's a generic error saying a probable cause is SQL Express default setup not allowing remote connections. Remote connections are turned on for both TCP and UDP. I can connect from within a small C# windows application using the same uid and pwd, so I suspect it's something related to IIS talking to SQLExpress. I would appreciate any help on other things to check. I am also fairly new to using IIS in the development environment.

Thanks

It could be because you didn't specify the instance name when you tried to connect from the C# app? It could also be that SQLBrowser isn't running.

Hope that helps,

John

|||

This is because SQL Server 2005 Express Edition does not accepts remote connections by default:

How to: Enable Network Access During Installation of SQL Server 2005 Express Edition

|||

Thanks John,

Yes, I specified the instance name and verified SQLBrowser is running. COnnection string = "Server=BUTTERFLY\SQLExpress; Initial Catalog=catalog; uid=username; pwd=password;

|||

Ronald,

Thanks for pointing me to this information. It didn't actually solve my dilemma, but it did get the juices flowing. This is related to a project I inherited and upgraded from .NET 1.1 to 2.0. The sql connection string referenced a property for "server=", changing this to "data source=" allowed the connection to open properly. I am reading the links you pointed and they are very helpful. Thanks

Can''t connect to SQL Express or SQL 2005 from C# web app and IIS

Hi all,

I'm new to this forum and haven't worked with SQL Server for a couple of years. Now it seems I'm getting back into it. I have SQL Express and SQL 2005 installed on an XP sp2 machine with IIS 5.1. I have a C#/ASP.NET web app in Visual Studio 2005 that keeps getting an error on attempting to connect (SqlConnection object). It's a generic error saying a probable cause is SQL Express default setup not allowing remote connections. Remote connections are turned on for both TCP and UDP. I can connect from within a small C# windows application using the same uid and pwd, so I suspect it's something related to IIS talking to SQLExpress. I would appreciate any help on other things to check. I am also fairly new to using IIS in the development environment.

Thanks

It could be because you didn't specify the instance name when you tried to connect from the C# app? It could also be that SQLBrowser isn't running.

Hope that helps,

John

|||

This is because SQL Server 2005 Express Edition does not accepts remote connections by default:

How to: Enable Network Access During Installation of SQL Server 2005 Express Edition

|||

Thanks John,

Yes, I specified the instance name and verified SQLBrowser is running. COnnection string = "Server=BUTTERFLY\SQLExpress; Initial Catalog=catalog; uid=username; pwd=password;

|||

Ronald,

Thanks for pointing me to this information. It didn't actually solve my dilemma, but it did get the juices flowing. This is related to a project I inherited and upgraded from .NET 1.1 to 2.0. The sql connection string referenced a property for "server=", changing this to "data source=" allowed the connection to open properly. I am reading the links you pointed and they are very helpful. Thanks

Can't connect to SQL Express 2005

I have a web app running on a laptop (for demo purposes) with the following connect string:

"datasource=<machine name>\SQLExpress;initial catalog=BlueTarp;User ID=sa;Password=xxx"

I can connect to this instance using both oSQL or sqlcmd and can select from the tables within BlueTarp, but my web app won't connect, and I can't figure out why!!

When I installed SQL Express, I used a named instance, called "SQLExpress".

I'm using mixed mode authentication.

One strange thing is that I can connect to either SQLExpress or MSSQLSERVER instances, but they appear to be the same instance -- I can use bluetarp in both.

when I use SQLExpress for instance name in web.config I get "SQL Server does not exist or access denied"

when I use MSSQLServer for instance name in web.config I get "Invalid connection"

And in fiddling with the web.config, I somehow did something to get a machine.config error, something like "machine.config couldn't be loaded because of an unloaded appdomain".

It's driving me nuts because I've spent a good 40 hours on this stupid problem, throwing the whole margin down the toilet.

Does anyone have any ideas?

Thank you,

Aarron

First, SQL Server has support for multiple protocols for remote connections (shared memory, named pipes, tcp/ip, and via) and if the client is trying a protocol the server has disabled then it will fail to connect.

To see what protocols are enabled, goto Computer Management -> SQL Server Configuration Manager -> SQL Server 2005 Network Configuration -> Protocols for <Instance Name>. If you change the protocols the server supports, you will need to restart the server.

Try using a protocol such as named pipes instead of shared memory. Try np:<machine name>.

http://msdn2.microsoft.com/en-US/library/system.data.sqlclient.sqlconnection.connectionstring(VS.80).aspx

For general troubleshooting of .NET connectivity issues, see this blog entry: http://blogs.msdn.com/sql_protocols/archive/2005/12/22/506607.aspx

For the ASP.NET issue, try restarting IIS/ASP.NET, and make sure machine.config is valid xml with the XML editor in Visual Studio.

|||

Mark,

Thanks so much for your help. I've been all over the web trying to find info about this problem -- people have pointed me to Mcaffe, to the .NET frameworks possibly having issues, to my web.config being poorly formatted.... and it turns out that I wasn't using a supported protocol. I enabled named pipes and it works like a charm.

You da man!

Aarron

Can't Connect to SQL 2005 Express Edition via Server Manangment Studio

I have installed SQL 2005 Express Edition on a Windows 2003 Web Edition server. Everything installed correctly, no errors to be found. I also have:

Local & Remote Connections using TCP/IP only turne don

SQL Browser is running as well.

I have tried connecting with the most recent CTP of Microsoft SQL Server Management Studio Express 9.00.1399.00

When trying to connect using the SA account I recieve:

'An error has occured while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (Provider: Named Pipes Provider, error 40 - Could not open a connection to SQL Server) (Microsoft SQL Server, Error: 53)

After that failed I tried creating a connection locally on the server using ODBC Manager with no luck as well.

Microsoft SQL Native Client Version 09.00.1399

Running connectivity tests...

Attempting connection
[Microsoft][SQL Native Client]TCP Provider: No connection could be made because the target machine actively refused it.

[Microsoft][SQL Native Client]Login timeout expired
[Microsoft][SQL Native Client]An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections.

TESTS FAILED!

Any help would be appreciated.


Try this.

Start > All Programs > Microsoft SQL Server 2005 > Configuration tools > SQL Server Surface Area Configuration

Then click Surface Area Configuration for Services and Connection. Select your instance of sql server (by default MSSQLSERVER). Then expand Database Engine and click on remote connections. On the right side select Local and remote connections > Using both TCO/IP and named pipes.

|||

I'm having the same issue, i've tried all of the above. My server has 9 active IP addresses, and I've tried connecting to the one which I use to remote in to the server. Is this the correct approach?

Also, in the SQL Server Configuration Manager, I've set that IP address to 'Active' and 'Enabled' with no luck. Same error as the gentleman above.

Any other suggestions?

Thank you,

Bret

|||I still can't get it to work. I've even tried the old remove and reinstall approach. This is very aggravating as I've tried everything under the sun that I can think of.|||

Got it working:

Under Protocols for SQLEXPRESS and tcp/ip and the ip addresses tab

Tcp dynamic ports – set to blank

Disabled other ips except the loopback

At the bottom, set dynamic ports to blank and the tcp port to 1433

Stopped and restarted the sql server.

Can't Connect to SQL 2005 Express Edition via Server Manangment Studio

I have installed SQL 2005 Express Edition on a Windows 2003 Web Edition server. Everything installed correctly, no errors to be found. I also have:

Local & Remote Connections using TCP/IP only turne don

SQL Browser is running as well.

I have tried connecting with the most recent CTP of Microsoft SQL Server Management Studio Express 9.00.1399.00

When trying to connect using the SA account I recieve:

'An error has occured while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (Provider: Named Pipes Provider, error 40 - Could not open a connection to SQL Server) (Microsoft SQL Server, Error: 53)

After that failed I tried creating a connection locally on the server using ODBC Manager with no luck as well.

Microsoft SQL Native Client Version 09.00.1399

Running connectivity tests...

Attempting connection
[Microsoft][SQL Native Client]TCP Provider: No connection could be made because the target machine actively refused it.

[Microsoft][SQL Native Client]Login timeout expired
[Microsoft][SQL Native Client]An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections.

TESTS FAILED!

Any help would be appreciated.


Try this.

Start > All Programs > Microsoft SQL Server 2005 > Configuration tools > SQL Server Surface Area Configuration

Then click Surface Area Configuration for Services and Connection. Select your instance of sql server (by default MSSQLSERVER). Then expand Database Engine and click on remote connections. On the right side select Local and remote connections > Using both TCO/IP and named pipes.

|||

I'm having the same issue, i've tried all of the above. My server has 9 active IP addresses, and I've tried connecting to the one which I use to remote in to the server. Is this the correct approach?

Also, in the SQL Server Configuration Manager, I've set that IP address to 'Active' and 'Enabled' with no luck. Same error as the gentleman above.

Any other suggestions?

Thank you,

Bret

|||I still can't get it to work. I've even tried the old remove and reinstall approach. This is very aggravating as I've tried everything under the sun that I can think of.|||

Got it working:

Under Protocols for SQLEXPRESS and tcp/ip and the ip addresses tab

Tcp dynamic ports – set to blank

Disabled other ips except the loopback

At the bottom, set dynamic ports to blank and the tcp port to 1433

Stopped and restarted the sql server.