Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Compiler Error CS0021

Status
Not open for further replies.

PIAS

Programmer
Nov 2, 2005
38
0
0
SI
What does mean this Error message?

Error Message
Cannot apply indexing with [] to an expression of type 'type'

i hawe variable that i use in FOR LOOP, like this;

Array myPozition;
int32 myAdd;
Int32 tempFor1 = pozicije.GetUpperBound(0);
for (i = 0; i <= tempFor1; i++)
{
myAdd = Convert.ToInt32(myPozition);
oCmd.Parameters["@advId"].Value = myAdd;
oCmd.Parameters["@pozition"].Value = i;
oCmd.ExecuteNonQuery();
}

...
 
What the error is saying that the type of oCmd.Parameters does not have an indexer on it. They usually look something like this in code:

MSDN said:
public int this [int index] // Indexer declaration
{
get
{
// Check the index limits.
if (index < 0 || index >= 100)
return 0;
else
return myArray[index];
}
set
{
if (!(index < 0 || index >= 100))
myArray[index] = value;
}
}

So, look at the datatype for the Parameters property on your oCmd object and see if it has an indexer.

Chip H.


____________________________________________________________________
If you want to get the best response to a question, please read FAQ222-2244 first
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top