Solved

SQLDataAdapter on WinForm and strongly typed data set for store procedures

Posted on 2012-03-22
3
360 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
Comment Utility
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
Comment Utility
        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
Comment Utility
thanks for the link
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
optimize  c# code 7 48
Duplicate a row 2 28
How do I bind the results to a grid 3 20
Check if number is currency 15 26
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
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…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

728 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now