SQL Server 2005/2008, db=user=schema=owner=’John’, ASP.net 2.0.50727, vb, IIS7
I’m moving website from one server to another. This piece of code works well on old server with SQL Server 2005.
Dim sqlCmdVehicle As SqlCommand = New System.Data.SqlClient.SqlCommand("SP_Name", sqlConn)
Dim dtVehicle As New DataTable
With sqlCmdVehicle
.Parameters.AddWithValue("FullStockNo", "N102010")
.CommandType = CommandType.StoredProcedure
End With
sqlConn.Open()
sqlAdapter.SelectCommand = sqlCmdVehicle
sqlAdapter.Fill(dtVehicle)
DB is backed up and successfully restored on new server. When I try to run with new SQL Server 2008 I got an error:
Could not find stored procedure ‘SP_Name’. pointing at last line.
I can see procedures with ‘MS SQL management studio’ not as dbo.SP_Name but as John.SP_Name
When I change
System.Data.SqlClient.SqlCommand("SP_Name", sqlConn)
into
System.Data.SqlClient.SqlCommand("John.SP_Name", sqlConn)
all works well, but it’s the same with all other procedures and a lot of such kind places in code 🙁
I got http://msdn.microsoft.com/en-us/library/ms189915.aspx, but caller’s default schema is correct.
Again, all works well on old box.
What should I fix in SQL to allow run SP without explicitly mentioned user/schema name?
Thank you.
=======================================
Unfortunately, I didn’t find fine solution. The way I took was search-and-replace SP_Name to John.SP_Name for the whole project. Thanks to all participants.
Unfortunately, I didn’t find fine solution. The way I took was search-and-replace SP_Name to John.SP_Name for the whole project. Thanks to all participants.