Solved

SQLDataAdapter on WinForm and strongly typed data set for store procedures

Posted on 2012-03-22
3
362 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

A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
This video teaches viewers about errors in exception handling.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.

770 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