Hi everyone , Im almost new do this subject Please help me if you can.
How to fill a data grid using a stored procedure
The stored proc name is purchase_transaction,there is an input parameter which is purchase_order_number1
The datagrids name is dgPo
Here is how my code looks like:
Even if you can think of another approach please help me with it.
How to fill a data grid using a stored procedure
The stored proc name is purchase_transaction,there is an input parameter which is purchase_order_number1
Code:
CREATE PROCEDURE dbo.Purchase_Transaction
(@Purchase_order_Number1 int ,@Purchase_transaction_id int output,@Purchase_Order_Number int output,@Item_id int output)
AS
select Purchase_transaction_id,Purchase_Order_Number,Item_id from Purchase_transactions
where Purchase_order_Number=@Purchase_order_Number1
RETURN
GO
The datagrids name is dgPo
Here is how my code looks like:
Code:
Dim myCmd1 As SqlCommand = New SqlCommand("Purchase_Transaction", objConn)
myCmd1.CommandType = CommandType.StoredProcedure
myCmd1.Parameters.Add("@Purchase_order_Number1", SqlDbType.Int)
myCmd1.Parameters("@Purchase_order_Number1").Value = CInt(txtOrderNo.Text)
myCmd1.Parameters("Purchase_order_Number1").Direction = ParameterDirection.Input
Dim dr2 As SqlDataReader
Try
objConn.Open()
dr2 = myCmd1.ExecuteReader()
While dr2.Read
bind dr2 to dgpo
DgPO= dr2.Item("purchase_transaction_id")
End While
Catch
End Try
DgPO.Enabled = False
End While
objConn.Close()
Catch exc As Exception
MsgBox(exc.Message)
End Try
Even if you can think of another approach please help me with it.