Israel

Israel

  • 699
  • 1.3k
  • 217.3k

the meaning of this: "IndexOutOfRangeException was unhandle"

Apr 29 2014 11:25 AM
Hi!
 
I am doing a simple filter after that my records should appear on textboxs I choose. But its appear only on the one I colored on blue (other one not. Why?)
I thought that its was the type of the "stocks" column. Before its was type="numeric" . I change to "nchar". But Still giving me this error "IndexOutOfRangeException was unhandle".
 
 
private void btnProcurarProdutoCons_Click(object sender, EventArgs e)
{
string connectionString = @"Data Source=localhost\sqlexpress;Initial Catalog=master;Integrated Security=True";
SqlConnection sqlCon = new SqlConnection(connectionString);
sqlCon.Open();
string commandString = "select produto from consultoria where produto='" + nomeProdutoConsStocks.Text + "'";
SqlCommand sqlCmd = new SqlCommand(commandString, sqlCon);
SqlDataReader read = sqlCmd.ExecuteReader();
while (read.Read())
{
produtoStocks.Text = read["produto"].ToString();// Here its appear
nStocksStocks.Text = read["n_stocks"].ToString();//Here its not appear
}
sqlCon.Close();
}
 

Answers (2)