am writing web appliction and running select query from access database but the query is only returning 73 rows
below is the code am using.
public void listboxload()
{
OleDbConnection con = new OleDbConnection();
con.ConnectionString = @"Provider=Microsoft.ACE.OLEDB.12.0;" + @"Data source=" + Server.MapPath("bin/InfinitieBanking1.accdb") + ";Jet OLEDB:Database Password=Promise";
con.Open();
string searchvalue = TextBox1.Text.Trim();
OleDbCommand cmd = new OleDbCommand("SELECT * FROM (SELECT * FROM Baacs)", con);
//cmd.Parameters.AddWithValue("?", "%" + searchvalue + "%");
OleDbDataAdapter da = new OleDbDataAdapter(cmd);
DataTable dt = new DataTable();
da.Fill(0, int.MaxValue, dt);
dt.Columns.Add("DisplayText", typeof(string));
Response.Write("loaded rows; " + dt.Rows.Count + "
");
foreach (DataRow row in dt.Rows)
{
string suic = row["suic"].ToString();
string acnam = row["acnam"].ToString();
row["DisplayText"] = string.Format("{0} - {1}", row["suic"], row["acnam"]);
}
ListBox1.DataSource = dt;
ListBox1.DataTextField = "DisplayText";
ListBox1.DataValueField = "suic";
ListBox1.DataBind();
}

Kapil Singh KumawatPosted Jun 4, 2025, 6:10 AM
PLease first the total records in source data set. Is it 73 or more ?
Marvin kakuruPosted Jun 5, 2025, 6:05 AM
THERE ARE 1,500 RECORDS IN MY DATABASE
Praveen KumarPosted Jun 2, 2025, 9:13 AM
How many records do you have in the table?
Also, this code is wrong.
OleDbCommand cmd = new OleDbCommand("SELECT * FROM (SELECT * FROM Baacs)", con);
you can use
OleDbCommand cmd = new OleDbCommand("SELECT * FROM Baacs", con);