Results 1 to 10 of 10

Thread: passing paramiters to sp's

Threaded View

  1. #1

    Thread Starter
    Fanatic Member carlblanchard's Avatar
    Join Date
    Sep 2003
    Location
    Bournemouth (UK)
    Posts
    539

    passing paramiters to sp's

    Can you help me im totally lost

    I have a stored procedure simple Insert one that works fine because ive tested it with query a
    ------------------------------------------------------------------------------

    Create Procedure InsRecord

    @RecordId int Output,
    @strTitle nvarchar(4),
    @strFirstName nvarchar(50),
    @strSurname nvarchar(50)
    AS

    Set NoCount On

    Declare @IntErrorCode Int
    Select @intErrorCode = @@error

    If @intErrorCode = 0
    Begin

    Insert into TelesalesData(Title,firstName,Surname)Values(@strTitle,@strFirstName,@strSurname)
    Select @intErrorCode = @@Error,
    @RecordId = @@Identity
    End
    Return @IntErrorCode


    GO
    -----------------------------------------------------------------------------
    However im having major problems

    is this the standard way to pass stuff to a stored proc

    Dim cn As New SqlConnection("Password=blah;Persist Security Info=True;User ID=blah;Initial Catalog=blah;Data Source=blah")
    Dim cmd As New SqlCommand("insRecord")
    cmd.Connection = cn
    cmd.CommandType = CommandType.StoredProcedure
    cmd.Parameters.Add(New SqlParameter("@strTitle", "Mr"))
    cmd.Parameters.Add(New SqlParameter("@strFirstName", "wolly"))
    cmd.Parameters.Add(New SqlParameter("@strSurname", "woo"))
    cmd.Connection.Open()
    cmd.ExecuteNonQuery()

    if not then what is the standard way to deal with SP's ?

    cheers in advance
    -------------------------------------------------------------------------------------
    ps all i get is this

    An unhandled exception of type 'System.Data.SqlClient.SqlException' occurred in system.data.dll

    Additional information: System error.
    Last edited by carlblanchard; Sep 25th, 2003 at 11:00 AM.
    I am curretly building a defect management system for software and web developers,
    If you wana try it out (beta test) and keep it for free just send me a message

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width