UPDATE Within An IF Statement Of A Stored Procedure
Feb 10, 2006
Hi
I want to run a stored procedure which updates a password. I
have the a table 'users' which has columns 'name' (as primary key) and
'pwd', which hold the username and password respectively. The
stored procedure accepts @username (the username), @pwdOld and @pwdNew
(the old and new passwords).
The following procedure returns 1 if the user inputs the correct old password.
strCreateStoredProcedure = " " & _
"CREATE PROC changePassword1 " & _
"( " & _
"@userName VarChar(20), " & _
"@pwdOld VarChar(50), " & _
"@pwdNew VarChar(50) " & _
") " & _
"AS " & _
"Declare @name VarChar(20) " & _
"Declare @actualPassword VarChar(50) " & _
"SELECT " & _
"@name = name, " & _
"@actualPassword = pwd " & _
"FROM users " & _
"WHERE name = @username " & _
"If @name is not null " & _
" If @pwdOld = @actualPassword " & _
" Return 1 " & _
" Else " & _
" Return -1 " & _
"Else " & _
"Return -1"
The following procedure updates the old password to the new password. So job done.
strCreateStoredProcedure = " " & _
"CREATE PROC changePassword2 " & _
"( " & _
"@userName VarChar(20), " & _
"@pwdOld VarChar(50), " & _
"@pwdNew VarChar(50) " & _
") " & _
"AS " & _
"Declare @name VarChar(20) " & _
"Declare @actualPassword VarChar(50) " & _
" UPDATE users " & _
" SET pwd = @pwdNew " & _
" WHERE name = @userName "
But using two procedures must be inefficient and slow. However, I
have not been able to combine the two. I would have thought I
should be able to replace "return 1" in the first procedure with the
UPDATE statement in the second procedure but I cannot save this
procedure.
I'm writing a fairly involved stored procedure. In this Stored Procedure, I have an update statement, followed by a select statement. The results of the select statement should be effected by the previous update statement, but its not. When the stored procedure is finish, the update statement seemed to have worked though, so it is working.
I suspect I need something, like a GO statement, but that doesnt seem to work for a stored procedure. Can anyone offer some assistance?
How to compare the Test_Result Column With Normal Values and Update the Test_Status Column for multiple rows in Transaction Table.
If my Test_Result value is less than Low Value of Normal_Values then i need to Update Test_Status as L and if Test_Result value is greater than High Value of Normal_Values then i need to Update Test_Status as H and if the Test_Result Value is in between Low and High Value of Normal_Values then i need to update a blank space
I have a query that brings back the data below. I need to divide the BudgetTotal by the Count. Then I need to go to the records that make up those €œgroups€? and enter a Budget value = BudgetTotal/Count.
How could I write this in a stored procedure or a SQL statement if possible?
Thanks.
Kevin
SELECT TOP 100 PERCENT dbo.ReportTable.ProjectNo, dbo.ReportTable.Category, dbo.ReportTable.Type, COUNT(dbo.ReportTable.ProjectNo) AS count, dbo.ReportTable.Budget, dbo.OracleDownloadBudget.Budget AS Expr1 FROM dbo.ReportTable INNER JOIN dbo.OracleDownloadBudget ON dbo.ReportTable.Category = dbo.OracleDownloadBudget.Category AND dbo.ReportTable.ProjectNo = dbo.OracleDownloadBudget.Project AND dbo.ReportTable.Type = dbo.OracleDownloadBudget.Type GROUP BY dbo.ReportTable.ProjectNo, dbo.ReportTable.ProjectName, dbo.ReportTable.Category, dbo.ReportTable.Type, dbo.ReportTable.Budget, dbo.OracleDownloadBudget.Budget HAVING (dbo.ReportTable.Budget < 1) ORDER BY dbo.ReportTable.ProjectNo
I am trying to create a stored procedure that will take a text value passed from an application and update a table using the corresponding integer value using a CASE statement. I get the error: Incorrect syntax near the keyword 'SET' when I execute the creation of the SP. What am I missing here? This looks to me like it should work. Here is my code.
CREATE PROCEDURE OfficeMove
-- Add the parameters for the stored procedure here
@UserName nvarchar(10),
@NewLocation nchar(5),
@NewCity nvarchar(250)
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
-- Insert statements for procedure here
Execute as user = '***'
DELETE FROM [SQLSZD].[SZDDB].dbo.Employee_Office_Assignments
WHERE User_Name = @UserName
INSERT INTO [SQLSZD].[SZDDB].dbo.Employee_Office_Assignments
hi need help how to send an email from database mail on row update from stored PROCEDURE multi update but i need to send a personal email evry employee get an email on row update like send one after one email
i use FUNCTION i get on this forum to use split from multi update
how to loop for evry update send an single eamil to evry employee ID send one email
How do you use an if then statement in a sql stored procedure? I have a table with 3 columns in it. When the tableis updated, I will only need one particular column in the database updated at a time. I will signal which column to update with an integer value(WhichColumn). So I want to key off that value to determine which column is to be updated. Here is my pseudo code if(WhichColumn EQUALS 1){ Update InsertEntry SET FirstColumn=Value}else if(WhichColumn EQUALS 2){ Update InsertEntry SET SecondColumn=Value}else if(WhichColumn EQUALS 3){ Update InsertEntry SET ThirdColumn=Value} Here is a rough start to my stored procedure to incorporate the logic aboveGOCREATE PROCEDURE [dbo].[InsertEntry]( WhichColumn int Value nvarchar(500), )
Hey all, don't know where I am going wrong on this, and maybe it's just that it can't be done. Below is the stored procedure and page code, and after that is the description of the prob************************* SP_GetDetails @wherestring varchar(400) ASSelect title_id, title, type, ytd_sales, pub_id from titles where title_id IN (@wherestring)*****************************This is the function that calls SP_GetDetails*****************************Public Function GetDetails(ByVal title As String) As DataViewDim DS As DataSetDim myconnection As SqlConnectionDim mycommand As SqlDataAdaptermyconnection = New SqlConnection(_ConnString)mycommand = New SqlDataAdapter("SP_GetDetails", myconnection)mycommand.SelectCommand.CommandType = CommandType.StoredProceduremycommand.SelectCommand.Parameters.Add(New SqlParameter("@wherestring", SqlDbType.VarChar, 400))mycommand.SelectCommand.Parameters("@wherestring").Value = titleDS = New DataSetTry mycommand.Fill(DS, "Details") Return DS.Tables("Details").DefaultViewCatch ex As Exception Throw exFinally myconnection.Close()End TryEnd Function****************************And this is the Function that Calls GetDetails:****************************Public Sub Get_Info(ByVal Sender As Object, ByVal e As EventArgs)Dim data As New DataLayerDim titles As String = ""Dim item As ObjectDim ltitle As StringDim i As Integer = 0For Each item In ListBox2.Items() If ListBox2.Items(i).Selected Then ltitle = ListBox2.Items(i).Value.ToString If (i > 0) And Not (titles = "") Then titles += ", '" & ltitle & "'" Else titles += "'" & ltitle & "'" End If End If ltitle = "" i += 1NextDataList1.DataSource = data.GetDetails(titles)DataList1.DataBind()End Sub****************************Problem:The DataSet is not getting any values. If I run the procedure in the QA with values that I know work, in the place of @wherestring, it works fine and I get the proper results. However if I try and give it a value (ie: Get_Info() returns "'BU1032', 'BU1111'", which are valid values, it doesn't respond) I have a feeling that its the way that the information @wherestring gets isn't formated right to be able to plug into the SP but I don't know any other way to do it...help is greatly appreciated and if you have any questions I will answer back immediately. thanks a ton. --Shred
I have a stored procedure that returns employee id's and how many shifts they have signed up for between 2 dates.
If they have less then 3 entries between the date range specified I would like update their status field to inactive.
So what I'm getting at is how would I go about doing an IF statement that would check through the results of my stored procedure to see who has worked less then 3 shifts and to execute another stored procedure to update their status.
I am creating am trying to create a stored procedure that looks to see what group_id number a user selected and if they select no group_id number than it should return one of a specific set that I specify in my procedure, but if they pick just one group_id number I only want it to return those records. Here is my procedure. When I run in Managment Studio it says I have errors near my if, then and else.
Any Ideas?? Thanks in advance!
CREATE PROCEDURE EMRUserSecurityGroups @group_id int
If @group_id = "*All" then SELECT c.user_id,c.first_name,c.last_name, b.group_id, b.group_name FROM user_group_xref a JOIN security_groups b on a.group_id= b.group_id JOIN user_mstr c on a.user_id=c.user_id WHERE b.group_id IN ('5','20','21','23','24','25','26','27','28','29','32') else SELECT c.user_id,c.first_name,c.last_name, b.group_id, b.group_name FROM user_group_xref a JOIN security_groups b on a.group_id= b.group_id JOIN user_mstr c on a.user_id=c.user_id WHERE b.group_id = @group_id
Hi Firends - What is good to use if we have to retrive records from SQL database. Should I use Stored procedures or should I write SQL statemnt in my Code.
Please let me know the advantages and disadvantages of both
Here's my stored procedure:CREATE PROCEDURE proc@id varchar(50),@pswd varchar(20),@no_go int OUTPUTASSET NOCOUNT ONSELECT user_id FROM tableWHERE user_id=@id AND pswd=@pswdIF @@ROWCOUNT = 0BEGINSET @no_go = 1ENDELSEBEGINSELECT date,date_mod FROM ansWHERE user_id=@idSET @no_go = 0ENDThis statement outputs the second recordset (SELECT FROM ans) whether@@ROWCOUNT is 0 or not. Why is that and how do I stop it
I have this code in a stored procedure: DECLARE @SQLString VarChar(200) SET @SQLString = 'SELECT ' + @LookupField + ' FROM ' + @DBTable + ' WHERE (' + @IDField + ' = ''' + @IDValue + ''')' Exec (@SQLString) it works fine - with just one issue - I must grant select permission on the table. Is there a way to do this WITHOUT granting the select permissions?
Is it necessary to include the Begin and End in this statement? IF @CId = '102' BEGIN SET @102 = 1 ENDOr, can it be rewritten as... IF @CId = '102' SET @102 = 1 Thanks all,Zath
Hello, I need a little help turning this:SELECT RequestNum FROM Tickets WHERE ReceiptDate>='" & FromDate & "' AND ReceiptDate<='" & ToDate & "'"into a sproc because of the two different values (FromDate and ToDate) for the ReceiptDate field in the database.I have this so far (problem areas are ??):Dim AuditConnection As New SqlConnection(ConnString)Dim AuditCommand As New SqlCommand("CreateAudit", AuditConnection)AuditCommand.CommandType = CommandType.StoredProcedureAuditCommand.Parameters.Add(New SqlParameter("@??", SqlDbType.NVarChar)).Value = FromDateAuditCommand.Parameters.Add(New SqlParameter("@??", SqlDbType.NVarChar)).Value = ToDateAuditConnection.Open()Dim AuditResult As SqlDataReader = AuditCommand.ExecuteReader()AuditGrid.DataSource = AuditResultAuditGrid.DataBind()AuditConnection.Close()and:CREATE PROCEDURE CreateAudit ?? ??ASSELECT RequestNumFROM TicketsWHERE ??AND ??GOI know I'm an idiot and this should be something simple. Arrrgh. Any help is appreciated immensely!!! :)
I'm trying to handle a stored procedure parameter. What needs to happen is that a particular statement shouldn't be executed if the parameter is empty. However, when I try it I get the following error:Cannot use empty object or column names. Use a single space if necessary.So, what's the correct way of doing the following?IF @filename <> ""BEGIN UPDATE Experimental_Images SET contentType = @contentType, filename = @filename WHERE (id = @iconNo)END
SELECT * FROM Cards WHERE CASE @Type = 1111 THEN CardType = 1111 ELSE CardType = 2222 END
GO
I know that the part after WHERE is wrong. But what I would like to achieve is this:
if the @type variable equals 1111 then get alla the rows with that value in the CardType-column. The same if @type = 2222, and if @type is any other value, then choose all rows regardles of the CardType value.
hi all, i'm wondering if i can use one stored procedure in too cases, this is the senario: i have stored procedure for admin and another one for user, they have the same select everything is the same except that in admin SP i have where @admin = admin and for user i have where @user = user if there a way to use if and else to make this happen this is what i did so far:
CREATE PROCEDURE [test] @admin INT, @user INT, @indexType INT as if @indexType = 1
begin
SELECT * FROM table WHERE something IN (SELECT * FROM anothertable where admin = @admin) end else begin SELECT * FROM table WHERE user = @user end GO
FoodID Integer PRIMARY KEY, FoodName varchar(255), FoodDesc text
How do I insert into this table while checking that the FoodName do not replicate? I'm aware that with a stored procedure I'm able to you the IF EXIST statement to help me solve this problem. But if I do not wish to use the stored procedure, am I able to create a SQL string to insert while checking the condition?
Thanks in advance to the people that replied to my request! Thanks so much...
SELECT ActivityCode AS 'Activity Code', ActivityDate AS 'Activity Date', ActDescription AS 'Activity Desc', ActDetail AS 'Activity Detail', ActSource AS 'Activity Source', ActPrjSource AS 'Activity Type', ActBillable AS 'Billable', ActBillRate AS 'Bill Rate', ActBilltoCCName AS 'Bill to Cost Center', (CASE WHEN ActARClosed = 1 Then 'Billed' Else 'Not Billed' END) AS 'Billed Status', ActBillingType AS 'Billing Type', ActBudType AS 'Budget Type', ActBudCat AS 'Budget Cat', ActBudSubCat AS 'Budget Sub Cat', ActCompMonth AS 'Company Month', ActCompWeek AS 'Company Week', ActCompYear AS 'Company Year', ActCostRate AS 'Cost Rate', ActCustName AS 'Customer', ActCustMngr AS 'Customer Manager', ActCustomerPct AS 'Customer Percentage', ActCustPO AS 'Customer PO', ActDataSplash AS 'Data Splash', ActDocId AS 'Document ID', ActEmpName AS 'Employee', ActEmpCCCode AS 'Employee CC Code', ActEmpCCGroup AS 'Employee CC Group', ActEmpCCName AS 'Employee Cost Center', ActEmpCCGrp3 AS 'Employee Department', ActEmpCCGrp2 AS 'Employee Division', ActEmpFTE AS 'Employee FTE', ActEmpMgr AS 'Employee Manager', ActEmpPos AS 'Employee Position', ActEMpTaskName AS 'Employee Task', (CASE WHEN ActFromType = 'Expense Report' THEN ActMoneyValue WHEN ActFromType = 'Purchase Request' THEN ActMoneyValue ELSE 0 END) AS 'Expenses' , ActFromType AS 'Form Type', ActGroups AS 'Groups', (CASE WHEN ActARClosed = 1 THEN ActBillTotal ELSE 0 END) AS 'Income', ActInvoiceNum AS 'Invoice Number', (CASE WHEN ActAPClosed = 1 Then 'Paid' Else 'Not Paid' END) AS 'Paid Status', ActPrjCCName AS 'Project Cost Center', ActPrjCCCode AS 'Project CC Code', ActPrjCode AS 'Project Code', ActPrjCCGrp3 AS 'Project Department', ActPrjSource as 'Project Source', ActPrjIndustry AS 'Project System', ActPrjMgr AS 'Project Manager', ActPrjName AS 'Project Name', ActPrjPhase AS 'Project Phase', ActPrjSponsor AS 'Project Sponsor', ActPrjType AS 'Project Type', ActTaskPhase AS 'Task Phase', (CASE WHEN ActFromType = 'Time Card' THEN ActTimeValue ELSE 0 END) AS 'Time', ActWeekEndDate AS 'Week Ending Date', ActPersFlowTxt1 AS 'Person Custom Text 1', ActPersFlowTxt2 AS 'Person Custom Text 2', ActPersFlowTxt3 AS 'Person Custom Text 3', ActProjFlowTxt1 AS 'Project Custom Text 1', ActProjFlowTxt2 AS 'Project Custom Text 2', ActProjFlowTxt3 AS 'Project Custom Text 3', ActHeaderCustom1 as 'Header Custom Text 1', ActHeaderCustom2 as 'Header Custom Text 2', ActHeaderCustom3 as 'Header Custom Text 3', ActHeaderCustom4 as 'Header Custom Text 4', ActDetailCustom1 as 'Detail Custom Text 1', ActDetailCustom2 as 'Detail Custom Text 2', ActDetailCustom3 as 'Detail Custom Text 3', ActDetailCustom4 as 'Detail Custom Text 4'
FROM ACTIVITIES WHERE ActivityDate BETWEEN @StartDate AND @EndDate AND (ISNULL(ActPrjName,'') LIKE @PrjName ) AND (ISNULL(ActEMpTaskName,'') LIKE @TaskName ) AND (ISNULL(ActEmpName,'') LIKE @EmpName )
GO SET QUOTED_IDENTIFIER OFF GO SET ANSI_NULLS ON GO
*************
The goal is to add another table called EMPLOYEES with fields E1 and E2 as part of the returned data set. I need a join statement but I can't figure out the syntax that will actually pull the data. Any help would be appreciated. Thanks.
When I created an SP in Enterprise Manager, I didn't manually type in the existence check at the inception, a la "if exists (select * from sysobjects...)". I just started with the CREATE PROC AS statement.
I noticed that if I generate a SQL script for the SP, SQL2000 automatically generates the existence check statement.
My question is, can I assume that when the SP is actually executed, SQL2000 does the exists check on its own? I EXEC'd the proc in Query Analyzer with no errors.
I just want to make sure that I don't need to enter the exists statement if it's already being done behind the scenes.
I am using C# to pass few paramenters to build the SQL statement in the stored procedure but when i run it i get this error:
Could not find stored procedure 'SELECT file_no, old_file_no, id_number, person_name FROM persons WHERE gender IN (null, 'MALE', 'FEMALE', 'OTHER') ORDER BY NAME'.
though the stored procedure dose exist and i don't have any problem when i staticaly write the sql statement in the stored procedure. can you pleas help..
here is my store dprocedure:
Code Block USE shefa set ANSI_NULLS ON set QUOTED_IDENTIFIER ON GO -- ============================================= -- Author: -- Create date: -- Description: -- ============================================= ALTER PROCEDURE [dbo].[sp_get_all_patients] @order_field varchar(255), @patient_gender varchar(255) AS BEGIN SET NOCOUNT ON; DECLARE @sql_statement varchar(255)
SET @sql_statement = 'SELECT file_no, old_file_no, id_number, person_name FROM persons ' + @patient_gender + ' ORDER BY ' + @order_field EXEC @sql_statement -- IF @order_field = 'FILE NO' -- SELECT file_no, old_file_no, id_number, person_name FROM persons ORDER BY file_no -- ELSE IF @order_field = 'OLD FILE NO' -- SELECT file_no, old_file_no, id_number, person_name FROM persons ORDER BY old_file_no -- ELSE -- SELECT file_no, old_file_no, id_number, person_name FROM persons ORDER BY person_name END
and here is my C#:
Code Block private void get_all_patients(string order_field, string patient_gender) { this.Cursor = Cursors.WaitCursor; data_table = new DataTable(); // sql_connection = new SqlConnection("Data Source=.\SQLEXPRESS;initial catalog=shefa;integrated security=true"); sql_connection = new SqlConnection(public_var.sql_connection); sql_command = new SqlCommand("sp_get_all_patients", sql_connection); sql_command.CommandType = CommandType.StoredProcedure; sql_command.Parameters.Add("@order_field", SqlDbType.VarChar).Value = order_field;
if (patient_gender == "ALL") sql_command.Parameters.Add("@patient_gender", SqlDbType.VarChar).Value = "WHERE gender IN (null, 'MALE', 'FEMALE', 'OTHER'"; else if (patient_gender == "MALE ONLY") sql_command.Parameters.Add("@patient_gender", SqlDbType.VarChar).Value = "WHERE gender ='MALE'"; else if (patient_gender == "FEMALE ONLY") sql_command.Parameters.Add("@patient_gender", SqlDbType.VarChar).Value = "WHERE gender ='FEMALE'"; else if (patient_gender == "OTHER") sql_command.Parameters.Add("@patient_gender", SqlDbType.VarChar).Value = "WHERE gender NOT IN ('MALE', 'FEMALE')"; else sql_command.Parameters.Add("@patient_gender", SqlDbType.VarChar).Value = "WHERE gender IN (null, 'MALE', 'FEMALE', 'OTHER')"; data_adapter = new SqlDataAdapter(sql_command); data_adapter.Fill(data_table); dataPatients.DataSource = data_table;
I have written a stored procedure which has in it a select statement. This returns a single record (I used the "top 1" line to ensure I only get a single record). I want to use a value returned by this statement (not the primary key) further on in the stored procedure - so assigning it to a variable would be handy.
Hi there, I am trying to return data from a select statement that is running a stored procedure.
I am running on SQL 2000 SP4. I have created a 'loopback' linked server as described in a technet article. (It's pointing at itself) I can then use the following select statement to get data back in the select statement from a stored procedure.
select * from openquery(loopback,'exec DWStaging.dbo.PokerStaging')
I am trying to get data back from my own Stored Procedure, but continue to get the following error:
Server: Msg 7357, Level 16, State 1, Line 1 Could not process object 'exec DWStaging.dbo.PokerStaging'. The OLE DB provider 'SQLOLEDB' indicates that the object has no columns. OLE DB error trace [Non-interface error: OLE DB provider unable to process the object:ProviderName='SQLOLEDB', Query=exec DWStaging.dbo.PokerStaging'].
If I try the same syntax with the sp_who stored procedure, it works and I get data back fine. But, If I try it with the sp_who2 stored procedure I get the same error as above.
select * from openquery(loopback,'exec sp_who') --> Works fine select * from openquery(loopback,'exec sp_who2') --> Doesn't work
Does anyone know what the difference is between the Stored Procedures that work with this syntax and those that don't? Is there a way I can change my stored procedure such that it would cause it to work?
PS: The following code was used to create the linked server, and then a security pass though as a certain account was addedDECLARE @provstr varchar (2000) SET @provstr = 'PROVIDER=SQLOLEDB;SERVER=' + @@SERVERNAME EXEC sp_addlinkedserver 'loopback', @srvproduct = 'MSSQL', @provider = 'SQLOLEDB', @provstr = @provstr
Can someone walk me through the code for my update_command event?Every article I read and every tutorial I walk through has a slightly different way of doing this task.It's confusing trying to understand which code-behind variables I need in my update_command event and how to pass them to a stored procedure. Please help me connect the dots. I have a SQL server table that looks like this (Both data types are char) Status_Id Status_DescriptionA ActiveP Planned I have a SQL stored procedure that looks like this… create procedure dbo.usp_Update_Status_Master(@status_id char(1),@status_description char(30))asupdate status_masterset status_description = @status_descriptionwhere status_id = @status_idGO Here is my code behind… Imports SystemImports System.DataImports System.Data.SqlClientImports System.ConfigurationImports System.Data.OdbcPublic Class WebForm1 Inherits System.Web.UI.Page Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load If Not IsPostBack Then Call LoadStatusMasterGrid() End If End Sub Public Sub LoadStatusMasterGrid() Dim connection As SqlConnection = New SqlConnection(ConfigurationSettings.AppSettings("sqlConn")) connection.Open() Try Dim command As SqlCommand = _ New SqlCommand("usp_Select_Status_Master", connection) Command.CommandType = CommandType.StoredProcedure Dim adapter As SqlDataAdapter = New SqlDataAdapter(Command) Dim table As DataTable = New DataTable adapter.Fill(table) dgStatusMaster.DataSource = table dgStatusMaster.DataKeyField = "status_id" dgStatusMaster.DataBind() Catch ex As Exception Console.WriteLine(ex.Message) Throw Finally connection.Close() End Try End Sub Private Sub dgStatusMaster_EditCommand(ByVal source As Object, _ ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles dgStatusMaster.EditCommand dgStatusMaster.EditItemIndex = e.Item.ItemIndex dgStatusMaster.DataBind() Call LoadStatusMasterGrid() End Sub Private Sub dgStatusMaster_CancelCommand(ByVal source As Object, _ ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles dgStatusMaster.CancelCommand dgStatusMaster.EditItemIndex = -1 Call LoadStatusMasterGrid() End Sub Private Sub dgStatusMaster_UpdateCommand(ByVal source As Object, _ ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles dgStatusMaster.UpdateCommand ‘ How do I code this part? End SubEnd Class Thanks in advance for taking the time.Tim
hi i have 2 columns linked ( 1 to a textbox and the other to drop down list) when i try to update i get 1 of the to the update SP but not the other and get this error Procedure or Function 'Update_ActiveCity' expects parameter '@Cities', which was not supplied.
_________________ this is the code of the aspx ____________
here is the procedureALTER PROCEDURE dbo.UpdateContact (@ContactId bigint,@FirstName nvarchar(50), @LastName nvarchar(50),@Telephone nvarchar(50), @Addressline nvarchar(150),@State nvarchar(100), @City nvarchar(100),@PostalCode varchar(50), @Email nvarchar(50), @MobilePhone varchar(50)) AS SET NOCOUNT ON UPDATE ContactSET FirstName = @FirstName, LastName = @LastName, Telephone = @Telephone, MobilePhone = @MobilePhone, Email = @Email, Addressline = @Addressline, City = @City, State = @State, PostalCode = @PostalCodeWHERE ContactId = @ContactId
RETURN what is the problem if i execute the storedprocedure separately it is working but when i call the storedprocedure in the code it fails. It gives an error as "syntax error near Updatecontact" Any ideas???