Click here to Skip to main content
15,921,179 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi i am new to visualstudio.net. I practice to build website using asp.net with c#. i am getting confused with data objects such as datareader, dataadapter, dataset. how the query is getting executed. how can i access data from sql using c#.net row by row.. please help me...
Posted

Use of SqlDataAdapter and Dataset
C#
SqlCommand cmd = new SqlCommand("your command ", con);
        
        cmd.CommandType = CommandType.Text;
        SqlDataAdapter da = new SqlDataAdapter(cmd);
        DataSet ds = new DataSet();
        da.Fill(ds);
        DataList2.DataSource = ds;
        DataList2.DataBind();

tell me if you got it
 
Share this answer
 
v2
You can use ADO.Net for it.
ADO.NET is a set of classes that expose data access services to the .NET programmer. ADO.NET provides functionality to developers writing managed code similar to the functionality provided to native COM developers by ADO. ADO.NET provides consistent access to data sources such as Microsoft® SQL Server™, as well as data sources exposed through OLE DB and XML. Data-sharing consumer applications can use ADO.NET to connect to these data sources and retrieve, manipulate, and update data.

A lots of article you can find on internet. Here are some link which will explain you the basics of accessing SQL Server through C#.
Beginners guide to accessing SQL Server through C#[^]
Using ADO.NET for beginners[^]
ADO.NET Basics[^]
Basic Database Operations in ADO.NET[^]
The C# Station ADO.NET Tutorial[^]
Video Article : How to Add, save & retrieve data in SQL Server using C# programming & Visual Studio[^]


--Amit
 
Share this answer
 
Go through the below to explore on ADO.NET.

1. [MSDN] ADO.NET[^].
2. [MSDN] ADO.NET Code Examples[^].
3. ADO.NET Lessons[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900