Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: SQL ADO.NET
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 5-Jan-13 0:25am
Comments
onurag19 at 5-Jan-13 6:33am
   
what do you want to ask ?
Sheikh Muhammad Haris at 7-Jan-13 0:29am
   
Really, didn't even get what you want to ask :)
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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.
  Permalink  
Comments
Sandeep Mewara at 13-Jan-13 3:26am
   
Yep. A 5!
Marcus Kramer at 14-Jan-13 11:15am
   
Thanks, Sandeep.
Maciej Los at 14-Jan-13 14:47pm
   
Agree! +5!
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

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;
            }
        }
  Permalink  

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

  Print Answers RSS
0 OriginalGriff 239
1 Sarvesh Kumar Gupta 185
2 George Jonsson 154
3 ArunRajendra 144
4 Richard MacCutchan 140


Advertise | Privacy | Mobile
Web04 | 2.8.140709.1 | Last Updated 13 Jan 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid