S
sam
I wanna use stored procedure by parameters (2 inputs) and I unsure I do the
right coding.
Stored Procedure
------------------
create procedure Opening_Balance (@Julian_Date_From, @Julian_Date_To,) as
select illitm, sum(qty) as qty, sum(weight) as weight
from f4111
where ildgl <> 0
and ildgl <= @Julian_Date_From
and ildgl >= @Julian_Date_To
and ilmcu like '%620%'
and illitm = '010720'
group by illitm
go
ASP.Net 1.1
--------------
Dim constr As String = "server='SQLSVR';Database='JDE_ERP_ARCHIVAL'"
Dim sqlcon As System.Data.SqlClient.sqlconnection = New
System.Data.SqlClient.sqlconnection(constr)
Dim sqlcmd As System.Data.SqlClient.SqlCommand = New SqlCommand()
Dim sqlda As New system.Data.SqlClient.sqldataAdapter()
Dim prm As New system.Data.SqlClient.SqlParameter()
Dim prm1 As New system.Data.SqlClient.SqlParameter()
Try
sqlcmd = sqlcon.CreateCommand
sqlcmd.CommandText = "[Opening_Balance]"
sqlcmd.CommandType = commandtype.StoredProcedure
prm = cmd.parameters.Add("(@Julian_Date_From",SqlDbType.Int, 6)
prm1 = cmd.parameters.Add("(@Julian_Date_To",SqlDbType.Int, 6)
prm.value = 105101
prm1.value = 105131
sqlda.SelectCommand = sqlcmd
sqlcon.Open
sqlcmd.ExecuteNonQuery
Finally
sqlcon.Close()
sqlcon.Dispose()
End Try
constr = Nothing
sqlcon = Nothing
sqlcmd = Nothing
sqlda = Nothing
Please advise.
Many thanks.
right coding.
Stored Procedure
------------------
create procedure Opening_Balance (@Julian_Date_From, @Julian_Date_To,) as
select illitm, sum(qty) as qty, sum(weight) as weight
from f4111
where ildgl <> 0
and ildgl <= @Julian_Date_From
and ildgl >= @Julian_Date_To
and ilmcu like '%620%'
and illitm = '010720'
group by illitm
go
ASP.Net 1.1
--------------
Dim constr As String = "server='SQLSVR';Database='JDE_ERP_ARCHIVAL'"
Dim sqlcon As System.Data.SqlClient.sqlconnection = New
System.Data.SqlClient.sqlconnection(constr)
Dim sqlcmd As System.Data.SqlClient.SqlCommand = New SqlCommand()
Dim sqlda As New system.Data.SqlClient.sqldataAdapter()
Dim prm As New system.Data.SqlClient.SqlParameter()
Dim prm1 As New system.Data.SqlClient.SqlParameter()
Try
sqlcmd = sqlcon.CreateCommand
sqlcmd.CommandText = "[Opening_Balance]"
sqlcmd.CommandType = commandtype.StoredProcedure
prm = cmd.parameters.Add("(@Julian_Date_From",SqlDbType.Int, 6)
prm1 = cmd.parameters.Add("(@Julian_Date_To",SqlDbType.Int, 6)
prm.value = 105101
prm1.value = 105131
sqlda.SelectCommand = sqlcmd
sqlcon.Open
sqlcmd.ExecuteNonQuery
Finally
sqlcon.Close()
sqlcon.Dispose()
End Try
constr = Nothing
sqlcon = Nothing
sqlcmd = Nothing
sqlda = Nothing
Please advise.
Many thanks.