473,387 Members | 1,779 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

One SP with two recordsets

I'm able to get one recordset from my SP that has two select statements. How
do I get the second recordset? How do I access the second recordset to
populate the tag of my controls?

Here is my code so far. I'm getting an error 'System.Data.DataTable' does
not contain a definition for 'Col' on ds.Tables[1].Col = 0;

string sConnString =
System.Configuration.ConfigurationSettings.AppSett ings["dsn"];
string sProc = "prGet_HIP";
using (SqlConnection oCn = new SqlConnection(sConnString))
{
using (SqlCommand oCmd = new SqlCommand(sProc, oCn))
{
oCn.Open();
oCmd.CommandType = CommandType.StoredProcedure;

oCmd.Parameters.Add("@sLicenseYear", SqlDbType.SmallInt,
2);
oCmd.Parameters["@sLicenseYear"].Value = intLicYear;

SqlDataAdapter oDa = new SqlDataAdapter();
oDa.SelectCommand = oCmd;
DataSet ds = new DataSet();
oDa.Fill(ds);

cboRails.DataSource = ds.Tables[0];
ds.Tables[1].Col = 0;
ds.Tables[1].Row = 0;
chkRailsNo.Tag = ds.Tables[1];
chkRailYes.Tag = ds.Tables[1];

cboWoodcook.DataSource = ds.Tables[0];
ds.Tables[1].Col = 0;
ds.Tables[1].Row = 1;
chkWoodcockYes.Tag = ds.Tables[1];
chkWoodcockNo.Tag = ds.Tables[1];


}
}

Nov 17 '05 #1
5 1356
Hi Cadel,

When the select command contains two select statements, one resultset will
be filled to the first table in the DataSet, while the second resultset
will be filled to the second table. Use ds.Table[1] to get the seconod one.

You're getting this error message, because you the DataTable class doesn't
contain a property named Col and Row. Please check the following link for
more information about the members of DataTable class.

http://msdn.microsoft.com/library/de...us/cpref/html/
frlrfsystemdatadatatablememberstopic.asp

If you're intending to do a databinding to the combobox, I suggest you
check the following link.

http://msdn.microsoft.com/library/de...us/vbcon/html/
vbtskdatabindingcomboboxcheckedlistboxorlistboxcon trol.asp

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

Nov 17 '05 #2
I read through the articles and changed my code. Now I'm getting a new error,
"Array was not a two-dimensional array." occurs on chkRailsNo.Tag =
foundRows.GetValue(0, 0);

Here is my code so far.

string sConnString =
System.Configuration.ConfigurationSettings.AppSett ings["dsn"];
string sProc = "prGet_HIP";
using (SqlConnection oCn = new SqlConnection(sConnString))
{
using (SqlCommand oCmd = new SqlCommand(sProc, oCn))
{
oCn.Open();
oCmd.CommandType = CommandType.StoredProcedure;

oCmd.Parameters.Add("@sLicenseYear", SqlDbType.SmallInt,
2);
oCmd.Parameters["@sLicenseYear"].Value = intLicYear;

SqlDataAdapter oDa = new SqlDataAdapter();
oDa.SelectCommand = oCmd;
DataSet ds = new DataSet();
oDa.Fill(ds);
DataRow[] foundRows = ds.Tables[0].Select();

chkRailsNo.Tag = foundRows.GetValue(0, 0);
chkRailYes.Tag = foundRows.GetValue(0, 0);
cboRails.DataSource = ds.Tables[1];
cboRails.DisplayMember = "Description";

chkWoodcockYes.Tag = foundRows.GetValue(1, 0);
chkWoodcockNo.Tag = foundRows.GetValue(1, 0);
cboWoodcook.DataSource = ds.Tables[1];
cboWoodcook.DisplayMember = "Description";
}
}

"Kevin Yu [MSFT]" wrote:
Hi Cadel,

When the select command contains two select statements, one resultset will
be filled to the first table in the DataSet, while the second resultset
will be filled to the second table. Use ds.Table[1] to get the seconod one.

You're getting this error message, because you the DataTable class doesn't
contain a property named Col and Row. Please check the following link for
more information about the members of DataTable class.

http://msdn.microsoft.com/library/de...us/cpref/html/
frlrfsystemdatadatatablememberstopic.asp

If you're intending to do a databinding to the combobox, I suggest you
check the following link.

http://msdn.microsoft.com/library/de...us/vbcon/html/
vbtskdatabindingcomboboxcheckedlistboxorlistboxcon trol.asp

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

Nov 17 '05 #3
Hi Cadel,

You're getting this error, because the foundRows is a one dimention array.
With this array, you can only get the DataRow with FoundRows.GetValue(0).
Or you can just use the index to get the DataRow directly. It returns a
DataRow object and then you get what you need from the DataRow. Change to
the following:

DataRow dr = foundRows[0];
chkRailsNo.Tag = dr[0];

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

Nov 17 '05 #4
That worked, but I see another problem. My combo boxes are all linked
together, so when the user changes a value in a combo box, all the combo
boxes get changed. How do I populate the collection of each combo box and
have each combo box indepentant?

Management didn't want the checkboxes, so now I'm only working with the
combo boxes.

string sProc = "prGet_HIP";
using (SqlConnection oCn = new SqlConnection(sConnString))
{
using (SqlCommand oCmd = new SqlCommand(sProc, oCn))
{
oCn.Open();
oCmd.CommandType = CommandType.StoredProcedure;

oCmd.Parameters.Add("@sLicenseYear", SqlDbType.SmallInt,
2);
oCmd.Parameters["@sLicenseYear"].Value = intLicYear;

SqlDataAdapter oDa = new SqlDataAdapter();
oDa.SelectCommand = oCmd;
DataSet ds = new DataSet();
oDa.Fill(ds);
DataRow[] foundRows = ds.Tables[0].Select();

DataRow dr = foundRows[0];
cboRails.Tag = dr[0];
cboRails.DataSource = ds.Tables[1];
cboRails.DisplayMember = "Description";

cboWoodcock.Tag = dr[0];
cboWoodcock.DataSource = ds.Tables[1];
cboWoodcock.DisplayMember = "Description";
}
}

"Kevin Yu [MSFT]" wrote:
Hi Cadel,

You're getting this error, because the foundRows is a one dimention array.
With this array, you can only get the DataRow with FoundRows.GetValue(0).
Or you can just use the index to get the DataRow directly. It returns a
DataRow object and then you get what you need from the DataRow. Change to
the following:

DataRow dr = foundRows[0];
chkRailsNo.Tag = dr[0];

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

Nov 17 '05 #5
Hi Cadel,

The comboboxes are linked because their values are binding to the same
datasource. Bind to different data sources so that they won't change
together.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

Nov 17 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Steve Jorgensen | last post by:
I keep having problems in which ADO disconnected recordset work under some circumstances, but lose all their data at other times, having no rows or fields, though the recordset object still exists....
1
by: lakshmi | last post by:
Hi all, I recently rewrote a data intensive C++ program in C#. The C++ program was traversing 3 recordsets that were all open at the same time. I replaced those 3 recordsets with 3 .NET data...
16
by: Randy Harris | last post by:
I was inspired by the recent discussion of returning multiple recordsets to ADO from a stored procedure. (Amazed is probably more accurate). I asked about how to accomplish same with Oracle and...
4
by: mrmagoo | last post by:
I'm building a vb.net Forms project that is getting data from a SQL Server database. One of the main goals of the project is to be really responsive to events, such as textbox change events. I...
4
by: rdemyan via AccessMonster.com | last post by:
Can someone help me with creating code that will look for DAO recordsets in modules and then check to see if the recordset is also closed in the module. All of my recordsets are of the form rs*...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.