I\'m coming over from PHP and am having a hard time with storing information into my newly created local database. I\'m using Microsoft Visual C# 2010 to help me learn and devel
Well, if you want a quick, almost close to the wire code like the way you used to have with PHP, the following code should work.
var conn = new SqlConnection("Your Connection String");
var command = conn.CreateCommand();
command.CommandText = "insert into sessions (id, name) values (@id, @name)";
command.Parameters.AddWithValue("@id", "");
command.Parameters.AddWithValue("@name", "test");
conn.Open();
command.ExecuteNonQuery();
command.Dispose();
conn.Close();
In the long run, it would be better if you get accustomed to one of the data-related / ORM frameworks such as Entity Framework, NHibernate and the likes. That would really help a lot in data manipulation and make your life a whole lot easier.