Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Stored procedure and typed dataset
Message
From
06/08/2003 14:04:42
Joel Leach
Memorial Business Systems, Inc.
Tennessee, United States
 
 
To
All
General information
Forum:
ASP.NET
Category:
ADO.NET
Title:
Stored procedure and typed dataset
Miscellaneous
Thread ID:
00817416
Message ID:
00817416
Views:
47
I'm learning how to call stored procedures with VS .NET, using the CustOrderHist stored procedure in the Northwind database. Basically, I have a test form with a textbox for the CustomerID, a DataGrid to display the results, and a button to execute the stored procedure. When I fill a plain, untyped dataset, everything works as expected. However, if I try to use a typed dataset, no records show up in the DataGrid (I do see the column headings). I suspect the problem may be the way I created the typed dataset. All I did was drag the CustOrderHist stored procedure from the Server Explorer to the dataset design area. Should I have done anything differently? Here is the code I am using:
string ConnectionString = "data source=JOEL-PC;initial catalog=Northwind;" + 
      "integrated security=SSPI;persist security info=True;workstation id=JOEL-PC;packet size=4096";
SqlDataAdapter MyTestAdapter = new SqlDataAdapter("CustOrderHist",ConnectionString);
MyTestAdapter.SelectCommand.CommandType = CommandType.StoredProcedure;
MyTestAdapter.SelectCommand.Parameters.Add(new SqlParameter("@CustomerID",SqlDbType.NChar, 5));
MyTestAdapter.SelectCommand.Parameters["@CustomerID"].Value = this.txtCustID.Text;

// *** this works ***
DataSet MyTestDataSet = new DataSet();

// *** this doesn't work ***
//SPDataset1 MyTestDataSet = new SPDataset1();

MyTestAdapter.Fill(MyTestDataSet);
this.dataGrid1.DataSource = MyTestDataSet.Tables[0];
Thanks.
Joel Leach
Microsoft Certified Professional
Blog: http://www.joelleach.net
Next
Reply
Map
View

Click here to load this message in the networking platform