GO CREATE PROCEDURE ViewMaintenance
@FormID nchar(5),
@SupplierID nchar(5),
@PlateNumber nchar(6)
AS SET NOCOUNT ON;
Select FormID, SupplierID,
PlateNumber, ServiceForm From Maintenance Where FormID = @FormID AND SupplierID = @SupplierID AND
PlateNumber = @PlateNumber AND ServiceForm IS NULL GO
And in code
SqlConnection conn = new SqlConnection("Data Source=JOSE-PC;Initial Catalog=AKDB;Integrated Security=True");
SqlCommand cmd = new SqlCommand("ViewMaintenance",conn);
cmd.CommandType = CommandType.StoredProcedure;
SqlParameter formid_param = cmd.Parameters.Add("@FormID", SqlDbType.Int);
SqlParameter supplierid_param = cmd.Parameters.Add("@SupplierID", SqlDbType.NChar,5);
SqlParameter platenumber_param = cmd.Parameters.Add("@PlateNumber", SqlDbType.NChar,6);
formid_param.Direction = ParameterDirection.Input;
supplierid_param.Direction = ParameterDirection.Input;
platenumber_param.Direction = ParameterDirection.Input;
formid_param.Value = Convert.ToInt32(txtFormNo.Text);
if(conn.State.Equals(ConnectionState.Closed))
{
conn.Open();
cmd.ExecuteNonQuery();
}
txtFormNo.Text = formid_param.ToString();
txtRequestedTo.Text = supplierid_param.ToString();
txtVehicle.Text = platenumber_param.ToString();
conn.Close();