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
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