473,614 Members | 2,101 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Problems with stored procedure not updating database

9 New Member
I have a stored procedure:

CREATE PROCEDURE [AddResident]
(
@residentID int OUTPUT,
@resNames [varchar](100),
@LName [varchar] (100),
@resAddress [varchar](50),
@resEMail [varchar](50),
@resPhone [varchar](50),
@statusID [int])

AS INSERT INTO [RHills].[dbo].[tblResidents]
( [resNames],
[LName],
[resAddress],
[resEMail],
[resPhone],
[statusID])

VALUES
( @resNames,
@LName,
@resAddress,
@resEMail,
@resPhone,
@statusID)

Select @@IDENTITY
GO

When I run this through the execute in Visual Web Developer 2005, it will update the database. When I enter this data in the webpage, it runs but does not update the database.

The code in the webpage is:
Protected Sub btnSubmit_Click (ByVal sender As Object, ByVal e As System.EventArg s) Handles btnSubmit.Click

Dim connectionStrin g As String = WebConfiguratio nManager.Connec tionStrings("RH illsConnectionS tring").Connect ionString

Dim con As New SqlConnection(c onnectionString )
Dim cmd As New SqlCommand("Add Resident", con)

cmd.CommandType = CommandType.Sto redProcedure

cmd.Parameters. Add(New SqlParameter("@ resNames", SqlDbType.VarCh ar, 100))
cmd.Parameters( "@resNames").Va lue = Me.txtNames.Tex t
cmd.Parameters. Add(New SqlParameter("@ LName", SqlDbType.VarCh ar, 50))
cmd.Parameters( "@LName").V alue = Me.txtLName.Tex t
cmd.Parameters. Add(New SqlParameter("@ address", SqlDbType.VarCh ar, 50))
cmd.Parameters( "@address").Val ue = Me.txtAddress.T ext
cmd.Parameters. Add(New SqlParameter("@ email", SqlDbType.VarCh ar, 50))
cmd.Parameters( "@email").V alue = Me.txtEmail.Tex t
cmd.Parameters. Add(New SqlParameter("@ phone", SqlDbType.VarCh ar, 15))
cmd.Parameters( "@phone").V alue = Me.txtPhone.Tex t
cmd.Parameters. Add(New SqlParameter("@ statusID", SqlDbType.Int, 4))
cmd.Parameters( "@statusID").Va lue = 1
cmd.Parameters. Add(New SqlParameter("@ residentID", SqlDbType.Int, 4))
cmd.Parameters( "@residentID"). Direction = ParameterDirect ion.Output

Try
con.Open()
cmd.ExecuteNonQ uery()

Catch ex As Exception

Finally
con.Close()
Me.txtLName.Tex t = ""
Me.txtNames.Tex t = ""
Me.txtPhone.Tex t = ""
Me.txtEmail.Tex t = ""
Me.txtAddress.T ext = ""



End Try

End Sub

Why wont this update the database with the new data?
Apr 2 '07 #1
2 1171
kenobewan
4,871 Recognized Expert Specialist
Are you getting any error? Are you writing the exception in the catch? I would double check the connection string. Try debugging - e.g. try writing the update statement in the code first and then use SP. HTH.
Apr 3 '07 #2
Bomac8
9 New Member
I put the catch error in the code. Seems there was a problem with the connection string. I fixed that. However, When I run it again, it still will not work. Is there possibly some incompatability problem using web developer express addition with SQL server 2000? It seems I can get the information from the database, but I cant insert into it.
Apr 3 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

3
2469
by: Ryan.Chowdhury | last post by:
This is a general question regarding the use of view and stored procedures. I'm fairly new to databases and SQL. I've created a SQL database using an Access Data Project ("ADP") and I'm satified with the table structure. I've moved on to building some front ends for our users. I'm running into situations where I want subreports to be built from queries that are dependent on the values in other controls. I've played with stored...
3
5570
by: Narayan Appachar | last post by:
Hi, We were able to build stored procedures without any problems till now. Now while building procedures, we are getting the following errors ------------------------------------------ Create stored procedure returns -7032. SQL7032N SQL procedure "TESTMD5_1" not created. Diagnostic file is "P7374587.log". SQLSTATE=42904
3
1654
by: Justin | last post by:
I am trying to do a simple update of a database using a stored procedure. I have get the following error when executing the code: "Procedure or function UpdateDetails has too many arguments specified." Here is my SP: ALTER PROCEDURE dbo.UpdateDetails @KeyID int
7
2215
by: Peter D.C. | last post by:
Hi I want to update data hold in several textbox controls on an asp.net form. But it seems like it is the old textbox values that is "re-updates" through a stored procedure who updates a SQL tabel. I know the SP works, because a smalldatetime-field in the database is changed. I've tried to disable viewstate on all textbox controls. Any ideas to solve this problem.
2
11502
by: syntego | last post by:
We commonly use triggers to log changes to our main tables to historical log tables. In the trigger, we create a concatenated string of the old values by casting them as follows: CAST(O.MYDATE AS CHAR(30)) When directly updating date fields in the main table, the logged value gets saved in the format YYYY-MM-DD as expected.
1
2962
by: amgupta8 | last post by:
Note: This problem occurred when I updated the JDK from 1.3.1 to 1.4.1 or 1.4.2. Nothing else was changed in the code, other than updating the JDK on the database server (dbm cfg parm jdk_path) and recompiling/executing the code with 1.4.1 (deploying the newly compiled stored procedure code as well). This is the original exception that I got before I tried any code modifications: java.io.IOException: invalid offset/length at...
1
2160
by: eighthman11 | last post by:
Hey everyone, Using Access 2003 and SQL Server 8.0 I have a stored procdure on SQL Server that is launched from my access database where I send the parms. The stored procedure on the server has several updating steps and delete steps. I do rollbacks on these steps so if one step fails all data returns to it status prior to the stored procedure being launched.
5
4068
by: Bogdan | last post by:
Hi, I have a stored procedure that uses JOINs to return columns from multiple tables. I also have another stored proc that that takes a series of params and updates multiple tables. I used the framework to auto-generate a table adapter specifying both stored procs as Get/Fill and Update. The problem is that columns from the JOINed table seem to marked as 'read-only' so trying to update a row results in an exception. BTW, by default a...
3
1577
by: Darkside12 | last post by:
Hi, I'm trying to build a dynamic query by form. The idea is that a user can select a table in the database via a combo box and this will then change all of the text box labels on the form to match the field headers for the selected table. It also hides any text boxes that are surplus to the number of fields of the selected table. The user can then add their search criteria into the text boxes and search the selected table. To achieve...
0
8176
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8120
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8620
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8265
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8423
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7047
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4048
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4115
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2560
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.