public DataTable dt_date(resbal obj)
{
connection();
string details = @"SELECT donor_contacts.name AS NAME, m_reserve_userdetails.res_no AS 'RESERVATION NO',
m_room_user.build AS 'BUILDING',m_room.roomno AS 'ROOM NO',DATE_FORMAT(intime,'%r') AS 'CHECK-IN TIME',
CASE WHEN m_room_user.rent =0 THEN 'Free' ELSE 'Pass' END AS 'Passtype' FROM m_reserve_userdetails,donor_contacts,m_room_user,m_room
WHERE m_reserve_userdetails.id = donor_contacts.id
AND m_room_user.donor_id = m_reserve_userdetails.user_id
AND m_reserve_userdetails.status=1
AND indate ='" + obj.date + "'";
OdbcCommand cmd = new OdbcCommand(details, con);
OdbcDataAdapter oda = new OdbcDataAdapter(cmd);
DataTable dt = new DataTable();
oda.Fill(dt);
return dt;
}
或者
公共数据表 dt_date(resbal obj) { connection();
StringBuilder datails = new StringBuilder();
datails.Append("SELECT donor_contacts.name AS NAME, ");
datails.Append("m_reserve_userdetails.res_no AS 'RESERVATION NO',");
datails.Append("m_room_user.build AS 'BUILDING',");
datails.Append("m_room.roomno AS 'ROOM NO',");
datails.Append("DATE_FORMAT(intime,'%r') AS 'CHECK-IN TIME',");
datails.Append("CASE WHEN m_room_user.rent =0 THEN 'Free' ");
datails.Append("ELSE 'Pass' END AS 'Passtype' FROM m_reserve_userdetails,");
datails.Append("donor_contacts,m_room_user,m_room");
datails.Append("WHERE m_reserve_userdetails.id = donor_contacts.id");
datails.Append("AND m_room_user.donor_id = m_reserve_userdetails.user_id");
datails.Append("AND m_reserve_userdetails.status=1");
datails.Append("AND indate ='" + obj.date + "'");
OdbcCommand cmd = new OdbcCommand(datails.ToString(), con);
OdbcDataAdapter oda = new OdbcDataAdapter(cmd);
DataTable dt = new DataTable();
oda.Fill(dt);
return dt;
}
我想知道,即使只有 8 个或 10 个附加项, stringBuilder 是否比 string 效果更好?正如我在上面添加的那样,我尝试对此进行查询。但我发现没有显着差异。此查询需要时间。我知道,很可能它需要查询优化。但是现在,我需要知道使用 stringBuilder 是否有任何进步,而只有 8 到 10 个附加项。提前致谢。