B
Brad Wood
While debugging a stored procedure in a test application, I was doing
this against an MS Access database in a button click event:
oleDbCommand1.Parameters[0].Value = textBox.Text;
object dude = oleDbCommand1.ExecuteScalar();
if ( dude == null )
{
MessageBox.Show("no result from stored proc");
}
else
{
txtAnother.Text = dude.ToString();
}
This works fine the first time it is called and any subsequent times as
long as the parameter passed in from the textBox doesn't change, but if
I change it to another string that should give me a valid result from
the stored procedure, the result of ExecuteScalar is null.
If I restart the application and use that new string from the beginning,
I get a valid result.
The connection remains open, and I'm not changing parameter collection
of the command object.
What the hell?
this against an MS Access database in a button click event:
oleDbCommand1.Parameters[0].Value = textBox.Text;
object dude = oleDbCommand1.ExecuteScalar();
if ( dude == null )
{
MessageBox.Show("no result from stored proc");
}
else
{
txtAnother.Text = dude.ToString();
}
This works fine the first time it is called and any subsequent times as
long as the parameter passed in from the textBox doesn't change, but if
I change it to another string that should give me a valid result from
the stored procedure, the result of ExecuteScalar is null.
If I restart the application and use that new string from the beginning,
I get a valid result.
The connection remains open, and I'm not changing parameter collection
of the command object.
What the hell?