allora anche con odbc passandogli i parametri in questa maniera:
SELECT b.idbene, b.codint, b.prog, b.nrinv, b.descr, m.matricola,
t.idtip, t.codtip, t.acmagest civcla, t.tipo,
c.idcostr, c.codcostr, c.acmagest civpro, c.costrutt1,
mo.idmod, mo.codmod, mo.acmagest civmod, mo.modello,
r.idreparto, r.codrep, r.nomerep,
u.iduuoo, u.coduuoo, u.nomeuuoo,
e.idente, e.codente, e.nomeente,
d.iddip, d.coddip, d.desdip
FROM beni b, mobili m, tipiapp t, costrutt c, modelli mo,
variazioni v, reparti r, uuoo u, enti e, OUTER (dipartim d)
WHERE b.idbene = m.idbene
AND m.idtip = t.idtip
AND m.idcostr = c.idcostr
AND m.idmod = mo.idmod
AND b.idbene = v.idbene
AND v.idvar IN (SELECT MAX(v1.idvar) FROM variazioni v1 WHERE v1.idbene = b.idbene)
AND v.idreparto = r.idreparto
AND r.iduuoo = u.iduuoo
AND r.idente = e.idente
AND u.iddip = d.iddip
AND b.fuoriuso = '0'
AND b.tiprec IN ("S","A")
AND (( t.codtip =?) or (? =""))
AND ((c.codcostr=?) or (? =""))
AND (( mo.codmod=?) or (? =""))
AND ((e.codente=?) or (? =""))
AND ((u.coduuoo=?) or (? =""))
AND (( r.codrep=?) or (? =""))
AND ((codint=?) or (?=""))
AND ((matricola LIKE ?) or (?=""))
//System.Data.Odbc.OdbcParameter p1 = new System.Data.Odbc.OdbcParameter("param1", Tipologia1.CodTip.Trim());
//System.Data.Odbc.OdbcParameter p2 = new System.Data.Odbc.OdbcParameter("param2", Tipologia1.CodTip.Trim());
//System.Data.Odbc.OdbcParameter p3 = new System.Data.Odbc.OdbcParameter("param3", Tipologia1.CodCostr.Trim());
//System.Data.Odbc.OdbcParameter p4 = new System.Data.Odbc.OdbcParameter("param4", Tipologia1.CodCostr.Trim());
//System.Data.Odbc.OdbcParameter p5 = new System.Data.Odbc.OdbcParameter("param5", Tipologia1.CodMod.Trim());
//System.Data.Odbc.OdbcParameter p6 = new System.Data.Odbc.OdbcParameter("param6", Tipologia1.CodMod.Trim());
//System.Data.Odbc.OdbcParameter p7 = new System.Data.Odbc.OdbcParameter("param7", Ubicazione2.CodEnte.Trim());
//System.Data.Odbc.OdbcParameter p8 = new System.Data.Odbc.OdbcParameter("param8", Ubicazione2.CodEnte.Trim());
//System.Data.Odbc.OdbcParameter p9 = new System.Data.Odbc.OdbcParameter("param9", Ubicazione2.CodUuoo.Trim());
//System.Data.Odbc.OdbcParameter p10 = new System.Data.Odbc.OdbcParameter("param10", Ubicazione2.CodUuoo.Trim());
//System.Data.Odbc.OdbcParameter p11 = new System.Data.Odbc.OdbcParameter("param11", Ubicazione2.CodRep.Trim());
//System.Data.Odbc.OdbcParameter p12 = new System.Data.Odbc.OdbcParameter("param12", Ubicazione2.CodRep.Trim());
//System.Data.Odbc.OdbcParameter p13 = new System.Data.Odbc.OdbcParameter("param13", TbInventario.Text.Trim());
//System.Data.Odbc.OdbcParameter p14 = new System.Data.Odbc.OdbcParameter("param14", TbInventario.Text.Trim());
//System.Data.Odbc.OdbcParameter p15;
//if (TbSerie.Text.Trim() != "")
//{
// p15 = new System.Data.Odbc.OdbcParameter("param15", "%" + TbSerie.Text.Trim() + "%");
//}
//else
//{
// p15 = new System.Data.Odbc.OdbcParameter("param15", "");
//}
//System.Data.Odbc.OdbcParameter p16 = new System.Data.Odbc.OdbcParameter("param16", TbSerie.Text.Trim());
//s.Parameters.Add(p1);
//s.Parameters.Add(p2);
//s.Parameters.Add(p3);
//s.Parameters.Add(p4);
//s.Parameters.Add(p5);
//s.Parameters.Add(p6);
//s.Parameters.Add(p7);
//s.Parameters.Add(p8);
//s.Parameters.Add(p9);
//s.Parameters.Add(p10);
//s.Parameters.Add(p11);
//s.Parameters.Add(p12);
//s.Parameters.Add(p13);
//s.Parameters.Add(p14);
//s.Parameters.Add(p15);
//s.Parameters.Add(p16);
System.Data.Odbc.OdbcDataAdapter a = new System.Data.Odbc.OdbcDataAdapter(s);
dw = new System.Data.DataView();
dw.Table = new DataTable("tabella");
a.Fill(dw.Table);
Session["ElencoBeni"] = dw;
GridView1.Visible = true;
GridView1.DataBind();
CI METTE UN SECOLO E SPESSO VA IN TIMEOUT PER TROVARE UN RECORD!!
MENTRE se faccio in quest'altro modo è quasi istantanero:
string query = "SELECT b.idbene, b.codint, b.prog, b.nrinv, b.descr, m.matricola," +
" t.idtip, t.codtip, t.acmagest civcla, t.tipo," +
" c.idcostr, c.codcostr, c.acmagest civpro, c.costrutt1," +
" mo.idmod, mo.codmod, mo.acmagest civmod, mo.modello," +
" r.idreparto, r.codrep, r.nomerep," +
" u.iduuoo, u.coduuoo, u.nomeuuoo," +
" e.idente, e.codente, e.nomeente," +
" d.iddip, d.coddip, d.desdip" +
" FROM beni b, mobili m, tipiapp t, costrutt c, modelli mo, " +
" variazioni v, reparti r, uuoo u, enti e, OUTER (dipartim d)" +
" WHERE b.idbene = m.idbene" +
" AND m.idtip = t.idtip" +
" AND m.idcostr = c.idcostr" +
" AND m.idmod = mo.idmod" +
" AND b.idbene = v.idbene" +
" AND v.idvar IN (SELECT MAX(v1.idvar) FROM variazioni v1 WHERE v1.idbene = b.idbene)" +
" AND v.idreparto = r.idreparto" +
" AND r.iduuoo = u.iduuoo" +
" AND r.idente = e.idente" +
" AND u.iddip = d.iddip" +
" AND b.fuoriuso = '0'" +
" AND b.tiprec IN ('S', 'A') " +
" AND (( t.codtip = '" + Tipologia1.CodTip.Trim() + "') or ('" + Tipologia1.CodTip.Trim() + "' = ''))" +
" AND ((c.codcostr='" + Tipologia1.CodCostr.Trim() + "') or ('" + Tipologia1.CodCostr.Trim() + "' = ''))" +
" AND (( mo.codmod='" + Tipologia1.CodMod.Trim() + "') or ('" + Tipologia1.CodMod.Trim() + "'=''))" +
" AND ((e.codente='" + Ubicazione2.CodEnte.Trim() + "') or ('" + Ubicazione2.CodEnte.Trim() + "' = ''))" +
" AND ((u.coduuoo='" + Ubicazione2.CodUuoo.Trim() + "') or ('" + Ubicazione2.CodUuoo.Trim() + "' = ''))" +
" AND (( r.codrep='" + Ubicazione2.CodRep.Trim() + "') or ('" + Ubicazione2.CodRep.Trim() + "' = ''))" +
" AND ((codint='" + TbInventario.Text.Trim() + "') or ('" + TbInventario.Text.Trim() + "' = ''))" +
" AND ((matricola LIKE '%" + TbSerie.Text.Trim() + "%') or ('" + TbSerie.Text.Trim() + "' = ''))";
System.Data.Odbc.OdbcConnection c = new System.Data.Odbc.OdbcConnection(ConfigurationManager.AppSettings.GetValues("ConnIntiv")[0]);
c.Open();
System.Data.Odbc.OdbcCommand s = new System.Data.Odbc.OdbcCommand();
s.CommandText = query;
s.Connection = c;
s.CommandType = System.Data.CommandType.Text;
System.Data.Odbc.OdbcDataAdapter a = new System.Data.Odbc.OdbcDataAdapter(s);
dw = new System.Data.DataView();
dw.Table = new DataTable("tabella");
a.Fill(dw.Table);
Session["ElencoBeni"] = dw;
GridView1.Visible = true;
GridView1.DataBind();
mah ...
mistero ..
cmq grazie del tuo interessamento