Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

SQLDataAdapter on WinForm and strongly typed data set for store procedures

Posted on 2012-03-22
3
363 Views
Last Modified: 2012-03-23
I am looking for a simple example of using the SqlDataAdapter control on a winform to read a stored procedure as a strongly typed dataset.
There are countless examples of creating your own control in code and then accessing it with a loosely typed set.

Can you point me towards a simple example?
 sqlConnection1.Open();
            sqlDataAdapter1.SelectCommand.BeginExecuteReader();
            DataTable da = new DataTable();
            sqlDataAdapter1.Fill(da);
            foreach (DataRow oneRow in da.Rows)
            {
               
            }

This code does not work because it is not Asychronous.
0
Comment
Question by:wilfordrocks
3 Comments
 
LVL 20

Accepted Solution

by:
BuggyCoder earned 500 total points
ID: 37752598
Read this article from msdn, step by step resolution to your problem:-
http://support.microsoft.com/kb/320714
         SqlConnection cn = new                                            
SqlConnection("server=localhost;uid=sa;pwd=abcd;database=northwind");
	SqlCommand cmd = new SqlCommand("select * from [Alphabetical list of products]", cn);
	SqlDataAdapter da = new SqlDataAdapter(cmd);
	dsProducts tds = new dsProducts();

	da.Fill(tds, tds.Tables[0].TableName);

Open in new window

0
 
LVL 5

Expert Comment

by:Aruiz04
ID: 37752621
        SqlConnection cn = new SqlConnection();
        SqlCommand cmd = new SqlCommand("StoreProcedureName", cn);
        SqlDataAdapter da = new SqlDataAdapter(cmd);
        DataTable dt = new DataTable("TableNameFromYourTypedDataset");
        da.Fill(dt);
        foreach (DataRow dr in dt.Rows)
        {
            //Process here
        }

Open in new window

0
 

Author Closing Comment

by:wilfordrocks
ID: 37758859
thanks for the link
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Windows Script Host (WSH) has been part of Windows since Windows NT4. Windows Script Host provides architecture for building dynamic scripts that consist of a core object model, scripting hosts, and scripting engines. The key components of Window…
Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.

766 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question