//存儲過程代碼
CREATE PROCEDURE [AddNewInvoiceInfo] (@sUserID int@sClaimMethod varchar()@sInvoiceNum
varchar()@sInvoiceDate datetime@sBuyCity varchar())AS
Insert Into SMB_InvoiceInfo (MemberIDClaimMethodInvoiceNumInvoiceDateInvoiceCity) Values
(@sUserID@sClaimMethod@sInvoiceNum@sInvoiceDate@sBuyCity)
return @@IDENTITY
GO
//調用存儲過程代碼
Dim CN As New SqlConnection()
Dim InvoiceID As String
Try
CNConnectionString = DBConStr
CNOpen()
Dim CMD As SqlCommand
CMD = New SqlCommand(AddNewInvoiceInfo CN)
CMDCommandType = CommandTypeStoredProcedure
CMDParametersAdd(New SqlParameter(@sUserID SqlDbTypeInt))
CMDParameters(@sUserID)Value = CInt(UserIDText)
CMDParametersAdd(New SqlParameter(@sClaimMethod SqlDbTypeVarChar ))
CMDParameters(@sClaimMethod)Value = TransNameText
CMDParametersAdd(New SqlParameter(@sInvoiceNum SqlDbTypeVarChar ))
CMDParameters(@sInvoiceNum)Value = InvoiceNumText
CMDParametersAdd(New SqlParameter(@sInvoiceDate SqlDbTypeDateTime))
CMDParameters(@sInvoiceDate)Value = InvoiceDateSelectedDateDate
CMDParametersAdd(New SqlParameter(@sBuyCity SqlDbTypeVarChar ))
CMDParameters(@sBuyCity)Value = BuyCityText
CMDParametersAdd(New SqlParameter(@sInvoiceID SqlDbTypeInt))
CMDParameters(@sInvoiceID)Direction = ParameterDirectionReturnValue
CMDExecuteNonQuery()
InvoiceID = CMDParameters(@sInvoiceID)ValueToString()
CMDDispose()
Catch ex As Exception
ResponseWrite(exToString())
Finally
CNClose()
End Try
From:http://tw.wingwit.com/Article/program/net/201311/11528.html