Bind DB data to a Data table (.Net)
public DataTable getStaff(string names)
{
DataTable dt = new DataTable();
try
{
using (OdbcCommand getStaffCom = new OdbcCommand("SELECT * FROM Staff where Names like('" + names + "')", sqlCon()))
{
OdbcDataAdapter adpterToViewStaff = new OdbcDataAdapter(getStaffCom);
adpterToViewStaff.Fill(dt);
if (dt.Rows.Count > 0) { return dt; }
return null;
}
}
catch (Exception viewStaff) { return null; }
}
Comments
Post a Comment