次のようなストアド プロシージャがあります。
ALTER procedure [dbo].[fetchkey]
@carid nvarchar(50) =null
as
begin
select t.TBarcode, t.Status,[dbo].[keyloc](t.status,@carid) as 'keylocation'
from Transaction_tbl t
where t.TBarcode=@carid
end
また、私はこのような機能を持っています:
ALTER function [dbo].[keyloc](@status numeric(18,2),@cardID VARCHAR(50)) RETURNS varchar(50)
as
begin
@Ename nvarchar(50)
, @keylocation Varchar(50)
if @status=0
begin
select @keylocation= 0
end
return @keylocation
end
ストアド プロシージャを実行しているときに、次のように出力されます。
TBarcode Status keylocation
53012364813 0 0
このデータをデータグリッドビューに直接入力しています。ここで私のvb.netコード
Dim cmd As New SqlCommand("fetchkey", con.connect)
cmd.CommandType = CommandType.StoredProcedure
cmd.Parameters.Add("@carid", SqlDbType.Int).Value = carid
da.SelectCommand = cmd
da.Fill(ds)
DGVDashBoard.DataSource = ds.Tables(0).
このようにバインドすると、データ グリッドビューで 3 列が表示されます。データ グリッド ビューでは、Tbarcode 値とステータス値のみを表示したいです。どうすればこれを達成できますか。方法を知っている人がいれば、助けてください。