Hi! I have a DataBase and a query (SQL on C#). My table is about airways. So program should find one or some flights with searching them by FLIGHT NUMBER. I have DataGridView with this table. So what should I do with query and DB to get a table (DataGridView) that has only information about flights with this number?
So this is my query:
ALTER PROCEDURE dbo.StoredProcedure2
(
@number int ,
@PrID text OUTPUT
)
AS
SET NOCOUNT ON
SELECT @PrID = Pr
FROM TimeTable
WHERE ([Flight num] = @number)
RETURN
And this thing doesn`t work:
SqlCommand cmd = new SqlCommand();
SqlConnection con = new SqlConnection();
con.ConnectionString = connectionString;
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandText = "[dbo.StoredProcedure1]";
cmd.Parameters.Clear();
SqlParameter p1 = cmd.Parameters.Add("@number", SqlDbType.Int);
SqlParameter p2 = cmd.Parameters.Add("@PrID", SqlDbType.Text);
p1.Direction = ParameterDirection.Input;
p1.Value = go.Text;
p2.Direction = ParameterDirection.Output;
//textBox1.Text = p2.Value.ToString(); here should be a table with chosen flights
con.Open();
try
{
cmd.ExecuteNonQuery();
MessageBox.Show("success!");
}
catch (Exception ex)
{
MessageBox.Show(ex.Source + ex.Message + ex.HelpLink);
}
con.Close();
What should i change? :)