so this is my code (still :p) but it says 'IndexOutOfRangeException was unhandled' but why does it say that error its not under 0, the number is 0 so is the first row (cant be too high), and what do they mean with: 'Make sure data column names are correct' where do I need to type data column names
pls help me :<
thx in advance

'IndexOutOfRangeException was unhandled' ??
Gy&#240;a
I have this:
private void Form1_Load(object sender, EventArgs e){
this.table1TableAdapter.Fill(this.database1DataSet.Table1);}
Iggy2
oman
Hi,
I'm guessing your table has no column, or, more likely, your data table has no rows. In you're code, you're assuming both - that your table has at least one column (that's probably true) and that it contains at least one row (that might not be so). Before executing the above line, test for row (and/or) column presence, like:
if (myInstance.Tables["Table1"].Rows.Count > 0){
object Timo = myInstance.Tables["Table1"].Rows[0].ItemArray[0];
}
else
{
// no rows...
}
Andrej
Kamii47
Ok. so you probably have some code where you're reading that data from the database table into your dataset Like, using table adapters to fill your dataset (myTableAdapter.Fill(myDataSet.MyDataTable)
Can you check if your data gets loaded properly into your local dataset
Andrej
MuscleHead
Sorry, didn't quite understand this one...
About adding rows... you can add rows manually (see ...Rows.Add method), or more common practice - get them from some database.
Andrej
Teo Lachev
ok i prolly made the question to 'easy' with reading a bit I know now what rows are(they are what I thought they were ^^) but I am not missing any or not not having any at that number, so why does it say i dont have rows
mwoehlke
Jakobdo
BRCEWANE
May i suggest some reading on data concepts in .NET framework Getting Started with Data Access page on MSDN is a good place to start...
Andrej
J.Mathes
MJWhiteman
CSharpShooter
I don't see your code, but here's how these things work... You define a dataset, containing some datatables with columns. You have to fill these tables with data, e.g. fill them with data rows". You either do this by reading data from the database (SQL Server, etc.) or by manually adding rows to those tables. Once you have data tables filled with the data, you can start using that data. You can check whether specific tables have data or not by setting a breakpoint on some code line, dealing with datasets, and then hover your mouse cursor over dataset/datatable variable and select the little maginifying lense.
Again, your code probably tries to access the first row (0) of your Table1. If your table has no rows in it, the row 0 doesn't exist in the data table and you get the IndexOutOfRangeException.
Andrej
t_1369
What exactly are you trying to do Where are you getting data from
Andrej
gabriel_333
That looks good. Now, try this:
object Timo = this.database1DataSet.Table1.Rows[0].ItemArray[0];
It's a variation of your code - it doesn't create a new dataset instance, but uses the table in the same dataset instance - Table1 should now be filled with the code line you posted. The complete code [note: I didn't include row count checking, as specified in one of the previous posts]:
private void Form1_Load(object sender, EventArgs e)
{
this.table1TableAdapter.Fill(this.database1DataSet.Table1);
object Timo = this.database1DataSet.Table1.Rows[0].ItemArray[0];
// check Timo here
}
Andrej