|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Deleting data by calling the stored procedure in the .NET
Hi, does anyone know how to delete data from the SQL database by calling the stored procedure in the Visual Basic.NET? Because I did the Delete hyperlink bounded inside a datagrid. I have already displayed the appointment date, time in the datagrid so I do not have to input any values inside it. I am having trouble calling from the .NET. The stored procedure itself can work in the SQL Server database. Can someone pls help? Thanks!
These are my codes for the .NET. Dim connStr As String = System.Configuration.ConfigurationSettings.AppSett ings("SqlConnection.connectionString") Dim dbConn As New SqlConnection Dim dr As SqlDataReader dbConn.ConnectionString = connStr Try dbConn.Open() Dim dbCmd As New SqlCommand dbCmd.Connection = dbConn dbCmd.CommandType = CommandType.StoredProcedure dbCmd.CommandText = "spCancelReservation" Dim dbParam As SqlParameter dbParam = dbCmd.Parameters.Add("@AppDate", SqlDbType.DateTime) dbParam.Direction = ParameterDirection.Input dbParam.Value = Session("AppDate") dbParam = dbCmd.Parameters.Add("@AppTime", SqlDbType.Char, 4) dbParam.Direction = ParameterDirection.Input dbParam.Value = Session("AppTime") dbParam = dbCmd.Parameters.Add("@MemNRIC", SqlDbType.Char, 9) dbParam.Direction = ParameterDirection.Input dbParam.Value = Session("NRIC") dr = dbCmd.ExecuteReader() Finally 'Re-direct to View page for display of reservation Server.Transfer("View.aspx") End Try End Sub For the part on red: it is supposed to be already displayed in the datagrid. So can i used a session to store it? For the part on green: it is supposed to just go into viewing the appointments after one has already logged in. So he is entited to view his own appt without having to input his NRIC no again. For the part on blue: I am supposed to delete the appt but this line of code is to add into the database right? So should I changed to dbCmd.Parameters.Clear()? If yes, how do I write? All the above are written inside the page_load event and all the data are being displayed as a datagrid. I created this page to do the behind scene of deleting without the user actually seeing it. So for the binding of the datagrid, wad should I typed for the URL and the URL field in the property builder as i used a hyperlink column to delete the appt? When the page is runned, the following occurred: A field or property with the name 'Cancel.aspx' was not found on the selected datasource. |
![]() |
| Viewing: ASP Free Forums > Database > Microsoft SQL Server > Deleting data by calling the stored procedure in the .NET |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|