Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Development Tools
 ASP.NET
 Index was outside the bounds of the array

Author  Topic 

shemayb
Posting Yak Master

159 Posts

Posted - 2007-07-16 : 15:04:27
i need help...thanks..i just want to ask about this kind of error:Index was outside the bounds of the array.

Funnyfrog

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2007-07-16 : 15:07:42
it means exactly what the error tells you.
you've tried to access an item with an index greater than the length of your array.


_______________________________________________
Causing trouble since 1980
blog: http://weblogs.sqlteam.com/mladenp
Go to Top of Page

shemayb
Posting Yak Master

159 Posts

Posted - 2007-07-16 : 15:10:41
the error is during my access to the stored procedure?

Funnyfrog
Go to Top of Page

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2007-07-16 : 15:13:24
well then we'll need to see your code.
i suspect you're trying to change a parameter that doesn't exists in your code.

_______________________________________________
Causing trouble since 1980
blog: http://weblogs.sqlteam.com/mladenp
Go to Top of Page

shemayb
Posting Yak Master

159 Posts

Posted - 2007-07-16 : 15:24:14
i am creating an insert stored procedure.The stored procedure is working.When i click the add button,i can add the item but the error index was outside the bounds of the array is still there.

Funnyfrog
Go to Top of Page

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2007-07-16 : 15:28:16
show us your .net code for calling the sproc.

_______________________________________________
Causing trouble since 1980
blog: http://weblogs.sqlteam.com/mladenp
Go to Top of Page

shemayb
Posting Yak Master

159 Posts

Posted - 2007-07-16 : 15:29:17
public int Add(string Description,bool Preemployment, bool Renewable, bool Required, bool Multiple, DateTime CREATE_DATE,DateTime LAST_UPDATE_DATE ,string LAST_UPDATE_USER_ID, string LAST_UPDATE_APP_NAME)
{
SqlParameter[] arParms = new SqlParameter[10];


arParms[0] = new SqlParameter("@Description", SqlDbType.VarChar);
arParms[0].Value = Description;

arParms[1] = new SqlParameter("@Preemployment", SqlDbType.Bit);
arParms[1].Value = Preemployment;

arParms[2] = new SqlParameter("@Renewable", SqlDbType.Bit);
arParms[2].Value = Renewable;

arParms[3] = new SqlParameter("@Required", SqlDbType.Bit);
arParms[3].Value = Required;

arParms[4] = new SqlParameter("@Multiple", SqlDbType.Bit);
arParms[4].Value = Multiple;

arParms[5] = new SqlParameter("@CREATE_DATE", SqlDbType.DateTime);
arParms[5].Value = DateTime.Today;

arParms[6] = new SqlParameter("@LAST_UPDATE_DATE", SqlDbType.DateTime);
arParms[6].Value = LAST_UPDATE_DATE;

arParms[7] = new SqlParameter("@LAST_UPDATE_USER_ID", SqlDbType.VarChar);
arParms[7].Value = LAST_UPDATE_USER_ID;

arParms = new SqlParameter("@LAST_UPDATE_APP_NAME", SqlDbType.VarChar);
arParms.Value = LAST_UPDATE_APP_NAME;

arParms[9] = new SqlParameter("@errnum", SqlDbType.Int);
arParms[9].Direction = ParameterDirection.Output;

string sConn = HHCUserManager.Instance.ConnectionString(_agencyId, _branchId);

HHDataAccessor da = new HHDataAccessor(sConn);
da.ExecuteNonQuery("insertCaregiverEmploymentRequirementType", arParms);

return (int.Parse(arParms[10].Value.ToString()));
}


Funnyfrog
Go to Top of Page

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2007-07-16 : 15:31:26
there is no arParms[10] in
return (int.Parse(arParms[10].Value.ToString()));


_______________________________________________
Causing trouble since 1980
blog: http://weblogs.sqlteam.com/mladenp
Go to Top of Page

shemayb
Posting Yak Master

159 Posts

Posted - 2007-07-16 : 15:38:16
thanks i got it..i have another error it is about the format of my input string.

Funnyfrog
Go to Top of Page
   

- Advertisement -