|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
I am trying to make a simple asp.net page that shows a grid view, textbox to enter a new item and a button that submits it through a stored procedure and populates an output parameter in a label. I am right now getting an error:
Conversion failed when converting the varchar value 'test4 has been submitted successfully' to data type int I am very new to programming so all suggestions are welcome. I havent found a tutorial for using varchar so if you know of one let me know ============= Storedprocedure ============= ALTER PROCEDURE [dbo].[Add_Addresstype] -- Add the parameters for the stored procedure here @t_Addresstype VarChar(50), @t_return VarChar(255) OUTPUT AS BEGIN IF EXISTS (SELECT t_AddressType From CM_AddressType WHERE t_AddressType = @t_Addresstype) BEGIN SET @t_return = 'The Address Type ' + @t_AddressType + ' already exists!' RETURN @t_return END ELSE BEGIN INSERT INTO CM_AddressType (t_addresstype) VALUES (@t_AddressType) Set @t_return = @t_AddressType + ' has been submitted successfully' RETURN @t_return END END ============= c# Code ============= SqlCommand cmd = new SqlCommand("Add_AddressType", CRMConnectionString); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@t_AddressType", txtAddressType.Text); cmd.Parameters["@t_AddressType"].Value = txtAddressType.Text; cmd.Parameters.Add(new SqlParameter("@t_return", SqlDbType.VarChar, 255)); cmd.Parameters["@t_return"].Direction = ParameterDirection.Output; CRMConnectionString.Open(); cmd.ExecuteNonQuery(); CRMConnectionString.Close(); string t_return = cmd.Parameters["@t_return"].Value.ToString(); lblreturn.Text = t_return; |
|
#2
|
|||
|
|||
|
Strange.....I commented ou the RETURN lines and it works now. i get my message and everything!
How would i refresh my gridview after the procedure is finisheD? |
![]() |
| Viewing: Dev Articles Community Forums > Programming > .NET Development > C# ado stored procedure (return messgae) |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|