So I'm playing around a little with SQL and C#. I have a .cs file in which I have a method where I'm gonna use a select to get some info from my database.
I think the syntax I'm using is correct (if not please let me know). But I was wondering which is the best way to store the result. Is there a way to store the result in datasets? If not, which is the best type to store the info?
So here goes my code:
SqlConnection con = new SqlConnection();
con.ConnectionString = (@"Data Source=XXXXXXXXXX.com;Initial Catalog=XXXXXXXXXX;User ID=XXXXXXXX;Password=XXXXXXXX");
SqlCommand cmd = new SqlCommand();
cmd.CommandText = "SELECT * FROM HISTHDR";
cmd.CommandType = CommandType.Text;
cmd.Connection = con;
con.Open();
int result = cmd.ExecuteNonQuery();
con.Close();
return true;
Thanks in advance!