// stored procedure code CREATE PROCEDURE [AddNewInvoiceInfo] (@sUserID int, @ sClaimMethod varchar (50), @ sInvoiceNum varchar (50), @ sInvoiceDate datetime, @ sBuyCity varchar (50)) ASInsert Into SMB_InvoiceInfo (MemberID, ClaimMethod, InvoiceNum, InvoiceDATE, INVOICECITY) VALUES (@ suserid, @ sclaimmethod, @ sinvoicenum, @ sinvoicedate, @ sbuycity) return @@ identityGO
// call the stored procedure code Dim CN As New SqlConnection () Dim InvoiceID As StringTry CN.ConnectionString = DBConStr CN.Open () Dim CMD As SqlCommand CMD = New SqlCommand ( "AddNewInvoiceInfo", CN) CMD.CommandType = CommandType.StoredProcedure
Cmd.parameters.add ("@ suserid", sqldbtype.int)) cmd.parameters ("@ suserid"). Value = cint (userid.text)
Cmd.Parameters.Add ("@ sclaimmethod", sqldbtype.varchar, 50)) cmd.parameters ("@ sclaimmethod"). Value = transname.text
Cmd.Parameters.Add (New Sqlparameter ("@ sinvoiceenum", sqldbtype.varchar, 50)) cmd.parameters ("@ sinvoiceenum"). Value = Invoicenum.Text
CMD.Parameters.Add ("@ sinvoicedate") cmd.parameters ("@ sinvoicedate"). Value = invoicedate.selectedDate.date
Cmd.Parameters.Add (New Sqlparameter ("@ sbuycity", sqldbtype.varchar, 50)) cmd.parameters ("@ sbuycity"). Value = BuyCity.Text
Cmd.parameters.add ("@ sinvoiceid", sqldbtype.int)) cmd.parameters ("@ SinvoiceID"). Direction = parameterDirection.ReturnValue