Use VB.NET to call stored procedures and get return values.

zhaozj2021-02-16  54

// 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

转载请注明原文地址:https://www.9cbs.com/read-23949.html

New Post(0)