Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 2.0 > ASP.NET 2.0 Basics
|
ASP.NET 2.0 Basics If you are new to ASP or ASP.NET programming with version 2.0, this is the forum to begin asking questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 6th, 2006, 10:31 AM
Friend of Wrox
 
Join Date: Oct 2005
Posts: 173
Thanks: 0
Thanked 2 Times in 1 Post
Default Database Connection not Behaving

Hi All

Could someone help me find what is wrong with the following piece of code?... for some reason it doesn't seem to do what it is supposed to do and update a record using the stored procedure... I have been looking at it for ages now but still cannot see anything wrong!..

Code:
Dim MyConnection As SqlConnection
Dim MyCommand As SqlCommand
Dim recID As SqlParameter
Dim recTitle As SqlParameter

Dim UpdateTitle As TextBox = FormView1.FindControl("TitleTextBox")


MyConnection = New SqlConnection()
MyConnection.ConnectionString = _
         ConfigurationManager.ConnectionStrings("myconnection").ConnectionString

MyCommand = New SqlCommand()
MyCommand.CommandText = "MY_UPDATE_SPROC"
MyCommand.CommandType = CommandType.StoredProcedure
MyCommand.Connection = MyConnection

recID = New SqlParameter()
recID.ParameterName = "@Rec_ID"
recID.SqlDbType = SqlDbType.Int
recID.Direction = ParameterDirection.Input
recID.Value = Request.QueryString("rec")

recTitle = New SqlParameter()
recTitle.ParameterName = "@rec_Title"
recTitle.SqlDbType = SqlDbType.VarChar
recTitle.Direction = ParameterDirection.Input
recTitle.Value = UpdateTitle.Text

MyCommand.Parameters.Add(recID)
MyCommand.Parameters.Add(recTitle)

MyCommand.Connection.Open()
myCommand.ExecuteNonQuery()
MyConnection.Dispose()
It is embedded within the code behind of an OnClick event.

Many thanks

Rit
__________________
Rit
www.designandonline.co.uk
INSPIRE | CREATE | DELIVER
 
Old July 7th, 2006, 10:55 PM
Friend of Wrox
 
Join Date: Nov 2003
Posts: 1,348
Thanks: 0
Thanked 5 Times in 5 Posts
Default

You will have to step through the code and make sure your parameters are being assigned the correct values. Then make sure your update SP is correct and running correctly.






Similar Threads
Thread Thread Starter Forum Replies Last Post
Database Connection to Access Database reachsevar ASP.NET 2.0 Basics 1 November 28th, 2007 08:56 AM
Cell Height not behaving nicely rodmcleay HTML Code Clinic 2 February 24th, 2006 10:43 AM
Access behaving badly mega Classic ASP Databases 6 November 17th, 2003 02:27 PM
EXE file behaving differently on different comp. Gert C++ Programming 3 September 18th, 2003 05:19 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.