//存储过程代码
CREATE PROCEDURE [AddNewInvoiceInfo] (@sUserID int,@sClaimMethod varchar(50),@sInvoiceNum varchar(50),
@sInvoiceDate datetime,@sBuyCity varchar(50))AS
Insert Into SMB_InvoiceInfo (MemberID,ClaimMethod,InvoiceNum,InvoiceDate,InvoiceCity)
Values (@sUserID,@sClaimMethod,@sInvoiceNum,@sInvoiceDate,@sBuyCity)
return @@IDENTITY
GO
//调用存储过程代码
2 Dim CN As New SqlConnection()
3 Dim InvoiceID As String
4 Try
5 CN.ConnectionString = DBConStr
6 CN.Open()
7 Dim CMD As SqlCommand
8 CMD = New SqlCommand("AddNewInvoiceInfo", CN)
9 CMD.CommandType = CommandType.StoredProcedure
10
11 CMD.Parameters.Add(New SqlParameter("@sUserID", SqlDbType.Int))
12 CMD.Parameters("@sUserID").Value = CInt(UserID.Text)
13
14 CMD.Parameters.Add(New SqlParameter("@sClaimMethod", SqlDbType.VarChar, 50))
15 CMD.Parameters("@sClaimMethod").Value = TransName.Text
16
17 CMD.Parameters.Add(New SqlParameter("@sInvoiceNum", SqlDbType.VarChar, 50))
18 CMD.Parameters("@sInvoiceNum").Value = InvoiceNum.Text
19
20 CMD.Parameters.Add(New SqlParameter("@sInvoiceDate", SqlDbType.DateTime))
21 CMD.Parameters("@sInvoiceDate").Value = InvoiceDate.SelectedDate.Date
22
23 CMD.Parameters.Add(New SqlParameter("@sBuyCity", SqlDbType.VarChar, 50))
24 CMD.Parameters("@sBuyCity").Value = BuyCity.Text
25
26 CMD.Parameters.Add(New SqlParameter("@sInvoiceID", SqlDbType.Int))
27 CMD.Parameters("@sInvoiceID").Direction = ParameterDirection.ReturnValue
28
29 CMD.ExecuteNonQuery()
30 InvoiceID = CMD.Parameters("@sInvoiceID").Value.ToString()
31 CMD.Dispose()
32 Catch ex As Exception
33 Response.Write(ex.ToString())
34 Finally
35 CN.Close()
36 End Try
37
posted on 2006-02-17 16:55
萌芽的叶子 阅读(1139)
评论(0) 编辑 收藏 引用 所属分类:
sql