Click here to Skip to main content
15,881,248 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
I have two tables
one emp and another dep
i want retrive one emp table values and another dept table values
in textboxes.
how can i do it in asp.net.
Posted
Updated 3-Feb-12 2:18am
v2
Comments
Anuja Pawar Indore 1-Feb-12 3:03am    
Not clear... Elaborate
OriginalGriff 1-Feb-12 3:08am    
And what is stopping you? Certainly I have no objections if you are seeking permission.
Use the "Improve question" widget to edit your question and provide better information.
Amir Mahfoozi 1-Feb-12 3:13am    
Search the internet. There are many samples out there.
Sudip Saha 1-Feb-12 3:35am    
Its a basic search in net how to connect data base using ADO.Net
Sergey Alexandrovich Kryukov 1-Feb-12 3:35am    
Not a question. Go ahead, you got my approval. :-)
--SA

Basic stuff, search. Here's a simple example tho...

C#
string commandText = "SELECT column1, column2 FROM MyTable Where Column1 IS NOT NULL"
var results = new DataSet();

var connectionString = ConfigurationManager
    .ConnectionStrings["MyConnectionStringName"].ConnectionString;

using (var connection = new SqlConnection(connectionString))
{
    connection.Open();
    using (var command = new SqlCommand(commandText, connection))
    {
        var adapter = new SqlDataAdapter(command);
        adapter.Fill(results);
    }
}

if (results.Tables.Count > 0)
{
    var firstTable = results.Tables[0];
    
    // Do something with the results
    foreach(var row in firstTable.Rows)
    {
        // do something??!
    }
}
 
Share this answer
 
Try query Select column1, column2 from table.
 
Share this answer
 
 
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