if i have the following data in my excel file,note that it may or may not have data from A-Z columns
A B C
1 1 97 testing
2 5 102 test
3 8 42 tessst
on a c# windows form there is a single test box that prompts the user for a row number,if they enter a row number of 1
then it must bring back only that single row.
what i attempted
private void btnGetRow_Click(object sender, EventArgs e)
{
var RowNumber = txtRowNumber.Text;
var path = "C:\\Book1.xlsx;";
if (txtRowNumber.Text == string.Empty || Convert.ToInt32(RowNumber) == 0)
{
MessageBox.Show("Please enter a digit > 0 ");
}
else
{
string con = " Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + path + ";Extended Properties=Excel 12.0;";
using (OleDbConnection connection = new OleDbConnection(con))
{
connection.Open();
OleDbCommand command = new OleDbCommand("select * from [Product$] where F1=Rownumber ", connection); // hear it must filter from the textbox,which it doesnt do so,it gives an error
using (OleDbDataReader dr = command.ExecuteReader())
{
while (dr.Read())
{
//here im not sure how to get the columns from A-Z
//send data to the printer
}
}
}
Console.WriteLine(RowNumber);
}
}