Going down to a deeper level in database to find stored procedure
using (SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["connectionstring"].ConnectionString))
{
conn.Open();
using (SqlCommand cmd = conn.CreateCommand())
{
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandText = "storedprocedure";
cmd.Parameters.AddWithValue("@param", param);
This connection string connects to the folder containing my databases, and I don't know how to access the stored procedure in one of those databases. 开发者_高级运维How would I delve deeper to get my stored procedure?
I'm not entirely sure what you mean by folders, but if this is SQL Server 2008, you'd just reference the database/owner(schema?)/name
ex:
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandText = "MyDatabase.dbo.MyProcedure";
cmd.Parameters.AddWithValue("@param", param);
Change your connection string to go to the database that you actually want to connect to. You should use the connection string as intended instead of trying to figure out a work around for this.
Take a look at this site for information on how to configure connection strings:
http://www.connectionstrings.com/sql-server-2008
精彩评论