Hi
I wrote below coding ,and last Message "Test" never appear in my project ,it means while loop never works.Plase tell me what is problem in my coding
public partial class Form1 : Form
{
public static int Number_Records;
public static DataSet ds;
public static DataTable dt;
public static int Next_Number;
public Form1()
{
InitializeComponent();
DataSet ds = new DataSet();
DataTable dt = new DataTable();
}
private void Form1_Load(object sender, EventArgs e)
{
DataTable dt1 = new DataTable();
SqlConnection con = new SqlConnection("Server=IT-Test;Database=NTY;user id=sa;password=12345");
try
{
con.Open();
string str = "select ExecutiveCode from dbo.RDExecutive order by ExecutiveCode";
SqlCommand cmd = new SqlCommand(str, con);
SqlDataReader CurrentOutLet1 = cmd.ExecuteReader();
int i = 0;
while (CurrentOutLet1.Read())
{
Number_Records= i++;
}
for (int y1 = 0; y1 < CurrentOutLet1.FieldCount; y1++)
{
// MessageBox.Show(CurrentOutLet1.FieldCount.ToString());
//MessageBox.Show(CurrentOutLet1.GetName(y1).ToString());
dt1.Columns.Add(CurrentOutLet1.GetName(y1),CurrentOutLet1.GetFieldType(y1));
}
while (CurrentOutLet1.Read())
{
MessageBox.Show("Test");
}
No "Test" message.
Thanks
Tank50