Click here to Skip to main content
15,867,308 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
how to update a table via WCF web service in Silverlight Application?
Posted
Comments
Eduard Keilholz 17-Feb-12 6:03am    
Can you explain more about the question's context, what have you tried already?

 
Share this answer
 
Comments
Nikhil_S 17-Feb-12 6:15am    
Thank you for the article but i know how to work in WCF with SQL Server problem is while updating a table via web service.
Jaganathan Bantheswaran 17-Feb-12 6:17am    
Then you should point out the error that you are getting... Please update the question..
the problem was passing the EmployeeID as SQL Parameters in this function under web service.


Public Sub UpdateEmpShiftDetails(employeeID As String, month As Integer, year As Integer, D1 As String, D2 As String, companyID As String, divisionID As String, departmentID As String, sectionID As String)
Dim connString As String = "Data Source=STORM-SERVER;Initial Catalog=HRNET1;Persist Security Info=True;User ID=sa;Password=its@123"
'Dim qry As String = "SELECT employee_id,attn_year,attn_month,day1,day2 FROM TNA_SHIFT_ROSTERING_DAILY"
Dim upd As String = "UPDATE TNA_SHIFT_ROSTERING_DAILY SET day1 = @day1, " & _
" day2 = @day2, " & _
"WHERE employee_id = @employee_id and " & _
"attn_month=@attn_month and " & _
"attn_year=@attn_year"

Dim conn As New SqlConnection(connString)
Try
conn.Open()

' Update employees
Dim cmd As New SqlCommand(upd, conn)
cmd.Parameters.Add("@day1", SqlDbType.VarChar, 5).Value = D1
cmd.Parameters.Add("@day2", SqlDbType.VarChar, 5).Value = D2
cmd.Parameters.Add("@employee_id", SqlDbType.VarChar, 10).Value = employeeID
cmd.Parameters.Add("@attn_year", SqlDbType.Int).Value = year
cmd.Parameters.Add("@attn_month", SqlDbType.Int).Value = month

Dim result = cmd.ExecuteNonQuery()



Catch e As Exception
Console.WriteLine("Error: " + e.Message)
Finally
conn.Close()
End Try
End Sub
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900