Missing rows in DataReader

J

JC

Hi,

I have a stored Proc being called from a a c# class that is passing a
resulting datareader back to a windows form , to build a drop down.
The really odd thing is, only a handfull of the records returned from
the SP actauly show up in the datareader - e.g. when I called the SP
in Query Analyser ti shows loads more records. I'm confused, so any
help woudl be appreciated. Thanks

**************************SP*******************************
CREATE PROCEDURE JC_TEST
AS
SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_CATALOG =
'MyDb' AND TABLE_NAME != 'dtproperties' AND TABLE_NAME !=
'sysconstraints' AND TABLE_NAME != 'syssegments' ORDER BY TABLE_TYPE
ASC, TABLE_NAME ASC
GO
************************************************************
************************DATACLASS****************************
public SqlDataReader GetTables()
{
string sSql = "JC_TEST";
SqlConnection oCon = new SqlConnection(_ConnectionString);
SqlCommand oCmm = new SqlCommand();
oCmm.Connection = oCon;
oCmm.CommandText = sSql;
oCmm.CommandType = CommandType.StoredProcedure;

oCon.Open();
SqlDataReader oDataReader =
oCmm.ExecuteReader(CommandBehavior.CloseConnection);
return oDataReader;
}
*****************************************************************
************************Form*************************************
private void PopulateTables()
{
System.Data.SqlClient.SqlDataReader oDr = oDd.GetTables();

while(oDr.Read())
{
comboBox1.Items.Add(oDr["TABLE_NAME"].ToString());
comboBox1.ValueMember = "TABLE_NAME";
label3.Text += oDr["TABLE_NAME"].ToString() + "\n";
}
oDr.Close();
}
****************************************************************

also, I'm quite new to .net, so if you can see any glaringly amatuer
things in my code please tell me. Thanks

JC
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top