Jump to content
Xtreme .Net Talk

Recommended Posts

Posted (edited)

Hi there...I have this problem with creating my first web service...I need to create a vb.net web service to add records to my sql server database... So can anyone here lend me a helping hand and give an example coding of the above problem...

Thanks..

:(

Edited by wan11
Posted

I have an Oracle example. SQL Server is similar. this one uses a stored proc but you could also use SQL strings if you prefer. Then you wouldn't need parameters just do something like :

INSERT INTO myTable (ID, string) VALUES (3,'parameter passed to web method')

 

 

<WebMethod(Description:="Paramter: aPath.")> _
   Function ClearF(ByVal apath As String) As String
       Dim Fert As String = String.Empty
       Dim objCmd As New OracleCommand(Fert, OracleConn)
       Dim P_PATH As New OracleParameter
       Try
           OracleConn.Open()
           With objCmd
               .CommandType = CommandType.StoredProcedure
               .CommandText = "USP_FRES"
               .Parameters.Add(P_PATH)
           End With

           'Create Parameter
           P_PATH.ParameterName = "P_PATH"
           P_PATH.DbType = DbType.String
           P_PATH.Direction = ParameterDirection.Input
           P_PATH.Value = apath

           objCmd.ExecuteNonQuery()
           Return "Success"
       Catch ex As Exception
           Return "Error : " & ex.Message
       Finally
           OracleConn.Close()
       End Try
   End Function

 

 

Hope this helps.

Wanna-Be C# Superstar
Posted

Thank you very much..Now i have 1 more question to ask...How can u create a login web service and the login information is in the database...? They have to register before they could go into my system...And their id and password are stored in the database...so could show me the coding in sql server..

thanks

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...