Reputation: 59
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);
Upvotes: 0
Views: 78
Reputation: 14781
I suggest Entity Framework Tutorials.
The ADO.NET Entity Framework supports data-centric applications and services, and provides a platform for programming against data that raises the level of abstraction from the logical relational level to the conceptual level. By enabling developers to work with data at a greater level of abstraction, the Entity Framework supports code that is independent of any particular data storage engine or relational schema.
References:
The ADO.NET Entity Framework Overview
Upvotes: 2
Reputation: 3412
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.
Upvotes: 2