S
Scott Newberry
Please pardon my ignorance on this one, but here's what I'm trying to do:
I have a table in a SQL Server 2000 DB called distributors. I've got an
ASPX which has a text box, a button, and two labels. In the textbox, the
user is to enter a "distributor id", then click the button. The button
should query the distributors table for a matching distributor id, and
return two prices, which is what the labels should reflect. Right now,
though, I'm not even trying to match up the distributor id. The table has
only one record in it at this time.
This is what I'm doing right now:
sqlConnection1.ConnectionString = blah blah blah;
sqlSelectCommand1.CommandText = "SELECT distid, colorprice, blackprice FROM
dbo.distributors";
sqlSelectCommand1.Connection = sqlConnection1;
private void Button1_Click(object sender, System.EventArgs e)
{
sqlConnection1.Open();
sqlDataReader MyReader = sqlSelectCommand1.ExecuteReader();
Label1.Text = MyReader.getSqlMoney(1).ToString();
Label2.Text = MyReader.getSqlMoney(2).ToString();
sqlConnection1.Close;
}
As you can see, right now, I'm not even trying to match up the distributor
id. I'm just trying to get the prices for the one record that's there.
After I get that working I'll want to start matching up the distributor id.
The error I'm getting is: Invalid attempt to read when no data is present.
Any ideas?
Thanks!
Scott
I have a table in a SQL Server 2000 DB called distributors. I've got an
ASPX which has a text box, a button, and two labels. In the textbox, the
user is to enter a "distributor id", then click the button. The button
should query the distributors table for a matching distributor id, and
return two prices, which is what the labels should reflect. Right now,
though, I'm not even trying to match up the distributor id. The table has
only one record in it at this time.
This is what I'm doing right now:
sqlConnection1.ConnectionString = blah blah blah;
sqlSelectCommand1.CommandText = "SELECT distid, colorprice, blackprice FROM
dbo.distributors";
sqlSelectCommand1.Connection = sqlConnection1;
private void Button1_Click(object sender, System.EventArgs e)
{
sqlConnection1.Open();
sqlDataReader MyReader = sqlSelectCommand1.ExecuteReader();
Label1.Text = MyReader.getSqlMoney(1).ToString();
Label2.Text = MyReader.getSqlMoney(2).ToString();
sqlConnection1.Close;
}
As you can see, right now, I'm not even trying to match up the distributor
id. I'm just trying to get the prices for the one record that's there.
After I get that working I'll want to start matching up the distributor id.
The error I'm getting is: Invalid attempt to read when no data is present.
Any ideas?
Thanks!
Scott