D
Doru Roman
Hi,
I have some difficulties in understanding how to use the connection,
dataset, datareader in a form.
Let's suppose I want to create a datareader and when I push a button to
bring another row from the dataset.
Supposedly I create under MyForm_Load event the connection, then a command
and the reader.
SqlConnection conn = new SqlConnection(...);
conn.open();
SqlCommand cmd = conn.CreateCommnad();
cmd.CommandType = ...
cmdCommnadText = ....
SqlReader dr = cmd.ExecuteReader();
If I try to use dr.Read() in side a ButtonRead_Click event, dr is not
recognized.
So, what is the approach here, where I create and use the components to make
them work?
Thanks,
Doru
I have some difficulties in understanding how to use the connection,
dataset, datareader in a form.
Let's suppose I want to create a datareader and when I push a button to
bring another row from the dataset.
Supposedly I create under MyForm_Load event the connection, then a command
and the reader.
SqlConnection conn = new SqlConnection(...);
conn.open();
SqlCommand cmd = conn.CreateCommnad();
cmd.CommandType = ...
cmdCommnadText = ....
SqlReader dr = cmd.ExecuteReader();
If I try to use dr.Read() in side a ButtonRead_Click event, dr is not
recognized.
So, what is the approach here, where I create and use the components to make
them work?
Thanks,
Doru