I want to work with data that I get from a SQL Server database directly in my ASP.NET code behind page. I have the connection string, should I use DataSet for accessing the data?
I want to work and customize data and then show it on an ASP.NET page in XML format (use it for xmlhttprequest answer).
Sample code would be greatly appreciated!
SqlConnection con = new SqlConnection("Data Source=.;Initial Catalog=user_city;Integrated Security=True");
con.Open();
SqlCommand my_command = new SqlCommand("select * from city_buildings where user_id=1",con);
There is many choices to get data from database. You wrote some code to directly retrieve data from database. You can see complete sample from MSDN: http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlcommand.aspx
There is also other methods: Entity Framework, NHibernate and etc.