A
Akeel
Hi I have the following code
char[] splitter={','};
string[] fields=row["DataLine"].ToString().Split(splitter)
string serviceDefintion=""
// row["DataLine"].ToString().Split(splitter
// conatins the followin
//"MigrationRef,ContactType,FirstName,LastName,MiddleName,Title
string _storedProcedure="create spProc @MigrationRef={0}, @ContactType={2}"
serviceDefintion=String.Format(_storedProcedure,fields)
// I would expect the value of _storedProcedure="create spProc @MigrationRef=MigrationRef, @ContactType=ContactType
I get an error when it tries this format :
ystem.SystemException: {"Index (zero based) must be greater than or equal to zero and less than the size of the argument list."
If I do the following it works fine
serviceDefintion=String.Format(_storedProcedure,fields[0],fields[1],fields[2])
The problem that I have is that the fields will vary in length from 2 items in the array to 55 items. I could create a case statement or I could do this in a loop but the string.format function seems perfect and I wonder if there is a differnt way I need to pass my array to it - can anyone help
Thanks in advance
Akeel
char[] splitter={','};
string[] fields=row["DataLine"].ToString().Split(splitter)
string serviceDefintion=""
// row["DataLine"].ToString().Split(splitter
// conatins the followin
//"MigrationRef,ContactType,FirstName,LastName,MiddleName,Title
string _storedProcedure="create spProc @MigrationRef={0}, @ContactType={2}"
serviceDefintion=String.Format(_storedProcedure,fields)
// I would expect the value of _storedProcedure="create spProc @MigrationRef=MigrationRef, @ContactType=ContactType
I get an error when it tries this format :
ystem.SystemException: {"Index (zero based) must be greater than or equal to zero and less than the size of the argument list."
If I do the following it works fine
serviceDefintion=String.Format(_storedProcedure,fields[0],fields[1],fields[2])
The problem that I have is that the fields will vary in length from 2 items in the array to 55 items. I could create a case statement or I could do this in a loop but the string.format function seems perfect and I wonder if there is a differnt way I need to pass my array to it - can anyone help
Thanks in advance
Akeel