Click here to Skip to main content
12,352,294 members (59,765 online)
Rate this:
 
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 5-Jan-13 6:33am
   
what do you want to ask ?
Sheikh Muhammad Haris 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 13-Jan-13 3:26am
   
Yep. A 5!
Marcus Kramer 14-Jan-13 11:15am
   
Thanks, Sandeep.
Maciej Los 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
Top Experts
Last 24hrsThis month


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

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100