473,486 Members | 2,427 Online
Bytes | Software Development & Data Engineering Community
Create 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.EventArgs) Handles btnSubmit.Click

Dim connectionString As String = WebConfigurationManager.ConnectionStrings("RHillsC onnectionString").ConnectionString

Dim con As New SqlConnection(connectionString)
Dim cmd As New SqlCommand("AddResident", con)

cmd.CommandType = CommandType.StoredProcedure

cmd.Parameters.Add(New SqlParameter("@resNames", SqlDbType.VarChar, 100))
cmd.Parameters("@resNames").Value = Me.txtNames.Text
cmd.Parameters.Add(New SqlParameter("@LName", SqlDbType.VarChar, 50))
cmd.Parameters("@LName").Value = Me.txtLName.Text
cmd.Parameters.Add(New SqlParameter("@address", SqlDbType.VarChar, 50))
cmd.Parameters("@address").Value = Me.txtAddress.Text
cmd.Parameters.Add(New SqlParameter("@email", SqlDbType.VarChar, 50))
cmd.Parameters("@email").Value = Me.txtEmail.Text
cmd.Parameters.Add(New SqlParameter("@phone", SqlDbType.VarChar, 15))
cmd.Parameters("@phone").Value = Me.txtPhone.Text
cmd.Parameters.Add(New SqlParameter("@statusID", SqlDbType.Int, 4))
cmd.Parameters("@statusID").Value = 1
cmd.Parameters.Add(New SqlParameter("@residentID", SqlDbType.Int, 4))
cmd.Parameters("@residentID").Direction = ParameterDirection.Output

Try
con.Open()
cmd.ExecuteNonQuery()

Catch ex As Exception

Finally
con.Close()
Me.txtLName.Text = ""
Me.txtNames.Text = ""
Me.txtPhone.Text = ""
Me.txtEmail.Text = ""
Me.txtAddress.Text = ""



End Try

End Sub

Why wont this update the database with the new data?
Apr 2 '07 #1
2 1156
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
2457
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...
3
5559
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...
3
1645
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...
7
2206
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...
2
11487
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: ...
1
2935
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...
1
2152
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...
5
4052
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...
3
1572
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...
0
7100
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,...
0
6964
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...
0
7126
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,...
1
6842
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...
0
7330
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...
0
5434
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,...
0
3070
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...
1
598
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
262
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.