With this code I'm retrieving the data from the database:
public static string[] SelectData(string data)
{
SqlConnection connection = Connection();
switch (connection.Equals(null))
{
case false:
var cmd = "SELECT command, properties FROM ai WHERE command = @command"
using (SqlCommand command = new SqlCommand(cmd, connection))
{
command.Parameters.AddWithValue("@command", data);
using (SqlDataReader reader = command.ExecuteReader())
{
switch (reader.Read())
{
case true:
connection.Close();
return reader["properties"].toString();
default:
connection.Close();
return null;
}
}
}
default:
connection.Close();
return null;
}
}
How do I store data stored in an database table like this:
property1,property2,property3,property4
In an array like this:
string[] propertyArray = { "property1", "property2", "property3", "property4" };
With invinite possible properties.
Best regards, Bradley Methorst
reader["properties"]isproperty1, property2, property3, property4, and you want to split that into an array? That's poor schema design: never put delimited data into a column.