Click here to Skip to main content
15,904,416 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
what is data source and how it is useful and can you tell me with code.i know a little about the data source but tell me working can u help me...
Posted

Data Source Controls:

Quote:
ASP.NET includes data source controls that allow you to work with different types of data sources such as a database, an XML file, or a middle-tier business object. Data source controls connect to and retrieve data from a data source and make it available for other controls to bind to, without requiring code. They can also support modifying data.

This topic provides information about the different types of data source controls in ASP.NET. The data source control model is extensible, so you can also create your own data source controls that interact with different data sources or that provide additional functionality for an existing data source.


In VB.Net

VB
Dim nwindConn As SqlConnection = New SqlConnection("Data Source=localhost;Integrated Security=SSPI;" & _"Initial Catalog=northwind")
nwindConn.Open()

[C#]
C#
SqlConnection nwindConn = new SqlConnection("Data Source=localhost; Integrated Security=SSPI;" + "Initial Catalog=northwind");
nwindConn.Open();
 
Share this answer
 
v2
Comments
_Amy 28-Feb-13 1:34am    
+5!
Data Source Controls Overview[^]

Data Source Controls[^]

Refer these links, you will understand what is the data source and what is the use.
 
Share this answer
 
v2
Hi friend...


With the help of Data Source Control, we can perform the data binding operation by writing some data access code. This is used to retrive a DataReader or a DataSet object from the server and you can show that retrived data in DataGrid, DropDownLIst or in ListBox.

Example:

SqlConnection con = new SqlConnection();

SqlCommand cmd = new SqlCommand("Select * from Emp", con);



SqlDataAdapter da = new SqlDataAdapter(cmd);



DataSet ds = new DataSet();

da.Fill(ds);



GridView1.DataSource = ds;

GridView1.DataBind();

Happy to help
 
Share this answer
 
Data Source Allows you to bind your controls directly with Datasets or Databse tables.

One of the Example is.

C#
Dataset ds = new Dataset();
ds = DBComponent.FillPlants();
DropdownList1.DataSource = ds.tables[0];
DropDwonlist1.DisplayField = "PlantName";
DropDwonlist1.ValueField = "PlantCode";



.......... so on.
 
Share this answer
 
v2

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