Re: Cannot add the data into the table
- From: BMW <BMW@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Wed, 10 Jan 2007 14:29:00 -0800
Hi Jens,
There is my code of vb.net and SQL stored procedure
Vb.Net:
Using scope As New TransactionScope()
Using cn As New SqlConnection(strConnection)
cn.Open()
Call testcurrentTransaction(Transaction.Current)
Using cmd As New SqlCommand("dbo.spDataTest", cn)
cmd.CommandType = CommandType.StoredProcedure
cmd.Parameters.Add("@Subject", SqlDbType.VarChar,
50).Value = cdo_msg.Subject
cmd.Parameters.Add("@Result", SqlDbType.VarChar,
100).Value = "testOct 12"
Dim par2 As New SqlParameter("@RowCount",
SqlDbType.Int)
par2.Direction = ParameterDirection.ReturnValue
cmd.Parameters.Add(par2)
cmd.ExecuteNonQuery()
Dim rowsAffected As Integer =
cmd.Parameters("@RowCount").Value
If (rowsAffected > 0) Then
Dim strResult As New StringBuilder
strResult.Append(bstrSubject).Append("Transaction was committed.
rowsAffected=").Append(rowsAffected)
Call sendMessage(strResult.ToString,
cdo_msg.Subject)
scope.Complete()
Else
Dim str As New StringBuilder
str.Append("Failed").Append("
rowsAffected=").Append(rowsAffected)
Call sendMessage(str.ToString, cdo_msg.Subject)
scope.Dispose()
End If
********************************
Stroed Procedure:
***********************************************************
Create PROCEDURE [dbo].[spDataTest]
-- Add the parameters for the stored procedure here
@Subject varchar(50),
@Result nvarchar(100)
AS
BEGIN
SET NOCOUNT ON;
-- Insert statements for procedure here
insert into dbo.Result (Subject, Result)values(@subject, @Result)
return @@rowcount
END
Thanks.
"Jens" wrote:
Hi,.
could you please post your code ?
HTH, Jens K. Suessmeyer.
---
http://www.sqlserver2005.de
---
- Follow-Ups:
- Re: Cannot add the data into the table
- From: Hugo Kornelis
- Re: Cannot add the data into the table
- References:
- Re: Cannot add the data into the table
- From: Jens
- Re: Cannot add the data into the table
- Prev by Date: Re: Cannot add the data into the table
- Next by Date: Re: Insert data
- Previous by thread: Re: Cannot add the data into the table
- Next by thread: Re: Cannot add the data into the table
- Index(es):
Relevant Pages
|
|