Click here to Skip to main content
15,887,683 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
This is a weird one.

So I'm cruising along developing a MVC5 web site, and everything is going pretty well, including using stored procs from the database.

Then I added a new call to the database. This call fails with the exception Keyword not supported 'initial catalog' when I try to create a SqlConnection object with the connection string.

If I comment out the call to hit the stored proc, ALL OTHER DATABASE TRANSACTIONS (using the same connection string) PROCEED NORMALLY. This led me to think there was something wrong with the stored proc, but sql server manager reports no errors, and I'm using the correct name and SqlParameter list.

I'm at a loss (and yes, I include the providerName property in the connection string key in web.config).

More Info:

0) I inspected the connection string at the point of failure, and it is an accurate representation of the way it's specified in the web.conf file.

1) The next database call in the app startup (both calls are in the same controller method) succeeds.

2) The stored proc in question is expecting a string that can be no longer than 36 characters, and the string I'm passing is only 32 characters.

3) It fails when I try to create the SqlConnection object, so the stored proc itself is not a factor in the failure.

4) If I move this call to follow another database call (that succeeds), this call still fails when I try to create the SqlConnection object.

What I have tried:

This info would essentially be a duplicate of my question. What a waste of bandwidth.
Posted
Updated 18-Mar-16 3:28am
v5
Comments
John C Rayan 18-Mar-16 8:33am    
Can you show us the connection string you are using and the version of SQL server.
#realJSOP 18-Mar-16 8:52am    
The connection string is not the problem.

<add name="DevConnection" connectionString="SERVER=[servername];Initial Catalog=[databasename];Integrated Security=SSPI" providerName="System.Data.SqlClient" />

Actual server/db names aren't necessary, and both the server and database in that sql instance exist (I'm sitting here looking at the database in SqlManager right now).

SqlServer 2008 R2.

Like I said, all other database access performed with that connection string work fine.
Richard Deeming 18-Mar-16 9:21am    
Shouldn't there be a Server= before the [servername]?

SqlConnection.ConnectionString Property[^]

Can you post the code for the call that fails?
#realJSOP 18-Mar-16 10:04am    
It's there, the cut/paste is screwed up on this system (DoD computer on a clown-based network) - I can't paste at all into some sites, and on some sites, it doesn't always paste all the copied text.

Weirdness. Without ANY changes to my code, it started working. I can only shrug my shoulders...
 
Share this answer
 
 
Share this answer
 
Comments
#realJSOP 18-Mar-16 8:49am    
The connection string IS NOT the problem. It works elsewhere in the code, and is not mangled in any way before I use it.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900