Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 .NET Inside SQL Server (2005)
 Alter Stored Procedure from within asp.net

Author  Topic 

vinno369
Starting Member

2 Posts

Posted - 2007-12-24 : 15:46:05
I want to alter a stored procedure from within my code base. I'm basically wanting to write an in house app that will update my stored procedures across many databases that we have. Any help would be appreciated. I'm having difficulty finding anything on this topic.

snSQL
Master Smack Fu Yak Hacker

1837 Posts

Posted - 2007-12-24 : 23:15:07
You'll need to be more specific, to change stored procs you just need to run ALTER PROCEDURE statements using a regular SqlConnection, SqlCommand and the ExecuteNonQuery method. More than that, I'm not sure what else you want to know?
Go to Top of Page

vinno369
Starting Member

2 Posts

Posted - 2007-12-25 : 15:31:35
snSQL, you must know what i'm getting at, cause somebody else on another forum was saying the same thing, which makes me think I am simply coding it wrong. Here is what I got.
Try
myCommand.CommandText = "Using " & DatabaseName & vbNewLine & Me.txtStoredProcedure.Text
myCommand.ExecuteNonQuery()
myTran.Commit()
Catch ex As Exception
myTran.Rollback()
Response.Write(ex.ToString())
End Try
Go to Top of Page

KenW
Constraint Violating Yak Guru

391 Posts

Posted - 2007-12-31 : 14:54:46
vinno369,

Getting snippy won't get you any help here.

You didn't post enough information, and what you did post is wrong. For example,


myCommand.CommandText = "Using " & DatabaseName & vbNewLine & Me.txtStoredProcedure.Text


You have a Commit() without a BeginTransaction().

"Using " & DatabaseName is wrong - it's invalid T-SQL. You would need "Use " & DatabaseName instead.

You'd also need a GO between the USE statement and the stored procedure.

You didn't post the contents of Me.txtStoredProcedure.Text.

You didn't provide any error message you were receiving.

Without the missing information, don't expect any help. You're simply not giving us enough to work with.
Go to Top of Page
   

- Advertisement -