Microsoft SQL Server
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsDatabaseMicrosoft SQL Server

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old August 2nd, 2005, 09:38 AM
littlevamp littlevamp is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Aug 2005
Posts: 1 littlevamp User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 m 25 sec
Reputation Power: 0
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.

Reply With Quote
Reply

Viewing: ASP Free ForumsDatabaseMicrosoft SQL Server > Deleting data by calling the stored procedure in the .NET


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway
Stay green...Green IT