Hi, I found this code on the internet but it doesn't work the way I want it to. You
can only search for data by numbers, but I want to search for mixed data. Any suggestions?
Important Namespaces Used
-------------------------
using System.IO;
using System.Data.OleDb;
--------------------------
Search Button Click Event Coding
-------------------------
String ExcelPath = Server.MapPath("~/ExcelFile/StudentRecord.xlsx");
OleDbConnection mycon = new OleDbConnection("Provider = Microsoft.ACE.OLEDB.12.0; Data Source = " + ExcelPath + "; Extended Properties=Excel 8.0;Persist Security Info = False");
mycon.Open();
OleDbCommand cmd = new OleDbCommand("select * from [Sheet1$] where rollno="+TextBox1.Text, mycon);
OleDbDataReader dr = cmd.ExecuteReader();
dr.Read();
if (dr.HasRows)
{
// Response.Write("<br/>"+dr[0].ToString());
TextBox2.Text =dr[1].ToString();
TextBox3.Text = dr[2].ToString();
TextBox4.Text = dr[3].ToString();
Label3.Text = "";
}
else
{
Label3.Text = "No Particular Roll Number Found";
TextBox2.Text = "";
TextBox3.Text = "";
TextBox4.Text = "";
}
mycon.Close();
---------------