![]() | |
![]() |
| | Thread Tools | Search this Thread | Display Modes |
#11
| |||
| |||
|
|
Are you sure that you execute SP from ASP.NET, does it work when table is not renamed? [quoted text clipped - 46 lines] -- Message posted via DotNetMonster.comhttp://www.dotnetmonster.com/Uwe/Forums.aspx/asp-net/201002/1 Here's the code that works SqlConnection conn = null; try { conn = new SqlConnection("...."); conn.Open(); SqlCommand cmd = new SqlCommand("DeleteDepartment", conn); SqlParameter p = new SqlParameter("@DepartmentID", xxx); cmd.Parameters.Add(p); cmd.CommandType = CommandType.StoredProcedure; cmd.ExecuteNonQuery(); } catch (Exception ex) { Response.Write("Error: " + ex.Message); } finally { if (conn != null) { conn.Close(); } } Tested against SQL Server 2000 - 8.00.2187 (x86) Enterprise Edition (Build 2195: Service Pack 4) Hope this helps |
#12
| |||
| |||
|
|
Alexey Smirnov wrote: Are you sure that you execute SP from ASP.NET, does it work when table is not renamed? [quoted text clipped - 46 lines] -- Message posted via DotNetMonster.comhttp://www.dotnetmonster.com/Uwe/Forums.aspx/asp-net/201002/1 Here's the code that works SqlConnection conn = null; * * * * * *try * * * * * *{ * * * * * * * *conn = new SqlConnection("...."); * * * * * * * *conn.Open(); * * * * * * * *SqlCommand cmd = new SqlCommand("DeleteDepartment", conn); * * * * * * * *SqlParameter p = new SqlParameter("@DepartmentID", xxx); * * * * * * * *cmd.Parameters.Add(p); * * * * * * * *cmd.CommandType = CommandType.StoredProcedure; * * * * * * * *cmd.ExecuteNonQuery(); * * * * * *} * * * * * *catch (Exception ex) * * * * * *{ * * * * * * * *Response.Write("Error: " + ex.Message); * * * * * *} * * * * * *finally * * * * * *{ * * * * * * * *if (conn != null) * * * * * * * *{ * * * * * * * * * *conn.Close(); * * * * * * * *} * * * * * *} Tested against SQL Server *2000 - 8.00.2187 (x86) Enterprise Edition (Build 2195: Service Pack 4) Hope this helps Thank you. I'll test it. I just check sql server in our company, they are only have sp2 installed. (sp4 is available for a long time). Is it cause problem of not catching error? -- Message posted via DotNetMonster.comhttp://www.dotnetmonster.com/Uwe/Forums.aspx/asp-net/201002/1 |
#13
| |||
| |||
|
|
Are you sure that you execute SP from ASP.NET, does it work when table is not renamed? [quoted text clipped - 42 lines] -- Message posted via DotNetMonster.comhttp://www.dotnetmonster.com/Uwe/Forums.aspx/asp-net/201002/1 Well, I don't think that this is a server issue. I think your code was wrong |
#14
| |||
| |||
|
|
On 8 Feb., 17:08, "aspfun via DotNetMonster.com" <u53138@uwe> wrote: Alexey Smirnov wrote: Are you sure that you execute SP from ASP.NET, does it work when table is not renamed? [quoted text clipped - 46 lines] -- Message posted via DotNetMonster.comhttp://www.dotnetmonster.com/Uwe/Forums.aspx/asp-net/201002/1 Here's the code that works SqlConnection conn = null; try { conn = new SqlConnection("...."); conn.Open(); SqlCommand cmd = new SqlCommand("DeleteDepartment", conn); SqlParameter p = new SqlParameter("@DepartmentID", xxx); cmd.Parameters.Add(p); cmd.CommandType = CommandType.StoredProcedure; cmd.ExecuteNonQuery(); } catch (Exception ex) { Response.Write("Error: " + ex.Message); } finally { if (conn != null) { conn.Close(); } } Tested against SQL Server 2000 - 8.00.2187 (x86) Enterprise Edition (Build 2195: Service Pack 4) Hope this helps Thank you. I'll test it. I just check sql server in our company, they are only have sp2 installed. (sp4 is available for a long time). Is it cause problem of not catching error? -- Message posted via DotNetMonster.comhttp://www.dotnetmonster.com/Uwe/Forums.aspx/asp-net/201002/1 Well, I don't think that this is a server issue. I think your code was wrong |
#15
| |||
| |||
|
|
Alexey Smirnov wrote: Are you sure that you execute SP from ASP.NET, does it work when table is not renamed? [quoted text clipped - 42 lines] -- Message posted via DotNetMonster.comhttp://www.dotnetmonster.com/Uwe/Forums.aspx/asp-net/201002/1 Well, I don't think that this is a server issue. I think your code was wrong I checked my code, it is the same as yours. |
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
| |