Reputation: 1
In asp.net I'm inserting array values into a database but array elements are not inserted properly. Instead of that, System.String[] is inserted.
Upvotes: 0
Views: 1351
Reputation: 36
System.String[] in the database implies that you are passing the string array directly to your database insert method.
Instead, you'll need to loop through the array and insert the strings as individual rows:
foreach(string s in stringArray)
{
database.Insert(s);
}
Alternatively, you can flatten the array and insert into a single row like this:
database.Insert(String.Join(",", stringArray))
This would insert the array as a comma-delimited list.
Upvotes: 1
Reputation: 35477
SQL does not do arrays well. You have mostly likely just done a .ToString()
on the array of strings.
Try using string.Join( ", ", mystrings)
.
As mentioned in the comments, this is not third normal form
. Search wikipedia for a good synopsis.
Upvotes: 4