Solved

SQLDataAdapter on WinForm and strongly typed data set for store procedures

Posted on 2012-03-22
3
365 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
[X]
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
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

What Is Transaction Monitoring and who needs it?

Synthetic Transaction Monitoring that you need for the day to day, which ensures your business website keeps running optimally, and that there is no downtime to impact your customer experience.

Question has a verified solution.

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

Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
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 clear a vector as well as how to detect empty vectors in C++.

719 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