Jump to content
Fórum Script Brasil
  • 0

Ajuda - Urgente!


Guest Fabíola

Question

Guest Fabíola

Pessoal, seguinte.. huh.gif

Onde trabalho, usamos o sql server, porém, eu tenho uma página que conforme serão cadastrados novos dados preciso atualizar ( insert ) uma outra base db2. alguém sabe como fazer isso???

wink.gif

Link to comment
Share on other sites

1 answer to this question

Recommended Posts

  • 0
Guest Marcella

Stored Procedure

CREATE PROCEDURE SetGroupEntity

@Name nvarchar(30) ,

@Description nvarchar(50) =NULL,

@flag int OUTPUT

AS

IF EXISTS(SELECT * FROM GroupEntity WHERE NAME=@NAME)

BEGIN

SET @flag=1

return @flag

END

ELSE

BEGIN

INSERT INTO GroupEntity([Name], [Description], LastUpdatedDate)

VALUES (@Name, @Description, CURRENT_TIMESTAMP)

Set @flag=0

return @flag

END

VB Functions

con = New SqlConnection(ConfigurationSettings.AppSettings("conBank"))

con.Open()

cmd = New SqlCommand

cmd.Connection = con

cmd.CommandType = CommandType.StoredProcedure

cmd.CommandText = "SetGroupEntity"

With cmd.Parameters

.Add("@Name", iName)

.Add("@Description", iDescription)

.Add("@flag", SqlDbType.Int) 'parameter return from stored procedure

End With

cmd.Parameters("@Name").Direction = ParameterDirection.Input

cmd.Parameters("@Description").Direction = ParameterDirection.Input

cmd.Parameters("@flag").Direction = ParameterDirection.Output

cmd.ExecuteNonQuery()

iFlag = cmd.Parameters("@flag").Value 'get return value

cmd.Dispose()

con.Close()

con.Dispose()

Link to comment
Share on other sites

Join the conversation

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

Guest
Answer this question...

×   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.



  • Forum Statistics

    • Total Topics
      152.2k
    • Total Posts
      651.8k
×
×
  • Create New...