Label1.Text=Card_Num;
try
{
this.oleDbDataAdapter1.SelectCommand.Parameters[1].Value = Card_Num.ToCharArray();
}
catch (Exception ex)
{
ErrorBox.Visible=true;
ErrorBox.Text=ex.ToString();
}
if(PIN.Text != bankDataset1.Cust_Pin.PINColumn.ToString())
{
LoginErrorMsg.Visible=true;
PIN.Text="";
PIN.MaxLength=4;
Customer_Number.Text="";
}
else
{
ChooseTrans(Card_Num);
}
}
Index out of range exception in C#Knew I should have paid attention in class
Page 1 of 1
4 Replies - 34462 Views - Last Post: 10 September 2007 - 07:49 PM
#1
Index out of range exception in C#
Posted 03 September 2007 - 07:52 AM
Below is my code and the information in the database is stored as type varchar. Label1 is a way of me testing to see if the right information is being passed and can be ignored at this point. If anyone can help, I would greatly appreciate it. This is the project that is due Weds.
Replies To: Index out of range exception in C#
#2
Re: Index out of range exception in C#
Posted 03 September 2007 - 07:57 AM
Well it seems theres an issue with the index of your Parameters for your oldb adapter. You need to post more code so I can try and help you
#3
Re: Index out of range exception in C#
Posted 06 September 2007 - 03:46 PM
i second psycocoder ,the problem must definately be with the adapters paramter index.
#4
Re: Index out of range exception in C#
Posted 06 September 2007 - 07:48 PM
I found out what I did wrong. I forgot to open the connection. You still have to open and close the connection even though you are using the drag and drop connection, dataadapter, and dataset. I got the project in a day late so that is not that bad, although I should have had it in Wednesday. Thanks for your help, though. It was much appreciated.
#5
Re: Index out of range exception in C#
Posted 10 September 2007 - 07:49 PM
The array index initalize in 0, not in 1.
Misguided, on 3 Sep, 2007 - 07:52 AM, said:
Below is my code and the information in the database is stored as type varchar. Label1 is a way of me testing to see if the right information is being passed and can be ignored at this point. If anyone can help, I would greatly appreciate it. This is the project that is due Weds.
Label1.Text=Card_Num;
try
{
this.oleDbDataAdapter1.SelectCommand.Parameters[1].Value = Card_Num.ToCharArray();
}
catch (Exception ex)
{
ErrorBox.Visible=true;
ErrorBox.Text=ex.ToString();
}
if(PIN.Text != bankDataset1.Cust_Pin.PINColumn.ToString())
{
LoginErrorMsg.Visible=true;
PIN.Text="";
PIN.MaxLength=4;
Customer_Number.Text="";
}
else
{
ChooseTrans(Card_Num);
}
}
Page 1 of 1
|
|

New Topic/Question
Reply




MultiQuote




|