Click here to Skip to main content
15,884,739 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Consider example where a windows form need to be created to display the product recorder data having record value equal to 750.The data will be fetched by sending SQL command to the database with the help of DbCommand object.
Posted
Comments
[no name] 5-Jan-13 6:33am    
what do you want to ask ?
[no name] 7-Jan-13 0:29am    
Really, didn't even get what you want to ask :)

Introduction to ADO.Net: Tutorial[^].
The best place to start when you are learning something new is a simple tutorial. These can almost always be found very quickly by typing a couple of your primary subjects into the search bar in google.
 
Share this answer
 
Comments
Sandeep Mewara 13-Jan-13 3:26am    
Yep. A 5!
fjdiewornncalwe 14-Jan-13 11:15am    
Thanks, Sandeep.
Maciej Los 14-Jan-13 14:47pm    
Agree! +5!
Assuming that your Sql connection is already created and also your sql command. This code can be called; you pass you sql command and your connection variable to it, it will return a datatable back to you to process and display in your form.

public DataTable ProcessCommand(string sql, SqlConnection conn)
       {
           SqlCommand _MiscCommand = default(SqlCommand);
           if (conn.State == ConnectionState.Closed)
           {
               conn.Open();
           }
           try
           {
               _MiscCommand = new SqlCommand(sql, conn);
               DataSet rsMiscAdapter = new SqlDataAdapter(_MiscCommand);
               DataTable table = new DataTable();
               rsMiscAdapter.Fill(table);
               return table;
           }
           catch (Exception )
           {
               return null;
           }
       }
 
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