|
-
October 13th, 2004, 04:06 PM
#1
get the value of output parameteres in visyal basic
Hay,
I want ask how i get the value of output parameteres in visyal basic .
i write code to send input parameteres and its work fine but i want to return 3 values
1-invoice Number
2-ID of inserted row
3-Error return
How i could get these values and how return to visual basic
-------------------------------
These my procedure in SQL Server2000 database:-
-------------------------------
CREATE PROCEDURE InsertNewBillNocustID
(
@type smallint = null
,@ftype smallint = null
,@hdate nvarchar(10) = null
,@gdate datetime = null
,@dateb1 nvarchar(10) = null
,@dateb2 nvarchar(10) = null
,@price1 money = null
,@price2 money = null
,@ftime nvarchar(8) = null
,@branchid uniqueidentifier = null
,@tmargin float = null
,@credit int = null
,@debit int = null
,@balance int = null
,@limit nvarchar(10) = null
,@sminvno nvarchar(15) = null
,@sminvdate nvarchar(10) = null
,@duedate nvarchar(10) = null
,@note nvarchar(500) = null
,@total money = null
,@discount float = null
,@discount2 float = null
,@total2 money = null
,@trkeb float = null
,@net money = null
,@custadd nvarchar(50) = null
,@custtel nvarchar(15) = null
,@custship nvarchar(50) = null
,@userid uniqueidentifier = null
,@temps bit = null
,@gqty int = null
,@wholepart bit = null
,@custtype bit = null
,@customerid uniqueidentifier = null
,@custname nvarchar(50) = null
,@saleman uniqueidentifier = null
,@lowsign nvarchar(1) = null
,@retinvno bigint output
,@reterror int output
,@retid uniqueidentifier output
)
AS
Declare @Invno bigint
Declare @ErrorCOde int
-- Get the maximum profile id and shove it into a variable
--begin transaction
SELECT @Invno = (SELECT MAX(invoiceno) from bill where type=@type)
-- Increment the variable
SELECT @Invno = @Invno + 1
begin transaction
insert into bill
(
type,ftype,hdate,gdate,dateb1,
dateb2,price1,price2,ftime,branchid,
tmargin,credit,debit,balance,limit,
sminvno,sminvdate,duedate,note,total,
discount,discount2,total2,trkeb,net,
custadd,custtel,custship,userid,temps,
gqty,wholepart,custtype,customerid,custname,
saleman,printed,trans,lowsign,
invoiceno
)
values (
@type,@ftype,@hdate,@gdate,@dateb1,
@dateb2,@price1,@price2,@ftime,@branchid,
@tmargin,@credit,@debit,@balance,@limit,
@sminvno,@sminvdate,@duedate,@note,@total,
@discount,@discount2,@total2,@trkeb,@net,
@custadd,@custtel,@custship,@userid,@temps,
@gqty,@wholepart,@custtype,
null,@custname,
@saleman,0,0,@lowsign,@invno)
set @errorcode=@@error
if (@errorcode=0)
begin
commit transaction
return(0)
end
else
begin
rollback transaction
return(@errorcode)
end
GO
-------------------------------
These code in visual basic :-
-------------------------------
Dim Aaa as string
Dim DB As New ADODB.Connection
DB.Open "Provider=sqloledb;Server=Test1;Database=mydatabase;Trusted_Connection=no;UID=sa;PWD=123123"
DB.CursorLocation = adUseClient
Aaa = ""
Aaa = "exec InsertNewBillNocustID"
Aaa = Aaa + " 3," & Comb_BillType.ItemData(Comb_BillType.ListIndex) & ",'" & TxtDate(0) & "','" & TxtDate(1) & "','" & TxtDate(4) & "',"
Aaa = Aaa + "'" & TxtDate(5) & "'," & Val(Text1(14)) & "," & Val(Label8) & ",'" & Format(Text1(3), "HH:MM:SS") & "','" & Cur_Branch & "',"
Aaa = Aaa + "" & Val(Label38(4)) & "," & Val(Label4(5)) & "," & Val(Label4(6)) & "," & Val(Label4(7)) & "," & Val(Label4(8)) & ","
Aaa = Aaa + "" & Val(Text1(4)) & ",'" & TxtDate(2) & "','" & TxtDate(3) & "','" & Text1(12) & "'," & Label20 & ","
Aaa = Aaa + "" & Val(Text1(6)) & "," & Val(Text1(13)) & "," & Label19 & "," & Val(Text1(5)) & "," & Val(Label21) & ","
Aaa = Aaa + "'" & Text5(0) & "','" & Text5(1) & "','" & Text5(2) & "','" & UserInfo(0) & "',0,"
Aaa = Aaa + "" & Val(Label10(3)) & "," & IIf(Option1.Value = True, 1, 0) & "," & IIf(Option3.Value = True, 1, 0) & ","
Aaa = Aaa + "null,'" & Text1(15) & "',"
Aaa = Aaa + "" & IIf(Comb_SaleMan <> "", "'" & Get_Name_New_ID("salemen", Comb_SaleMan) & "'", "Null") & "," & LowSign
DB.Execute Aaa
-
October 13th, 2004, 05:14 PM
#2
Re: get the value of output parameteres in visyal basic
instead of using the connection object and the execute method to run your stored proc, use a command object and parameter objects. Check out this thread, or do a search on "PARAMETERS" and "STORED"
http://www.codeguru.com/forum/showthread.php?t=275357
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|