Problemi dataset

venerdì 08 settembre 2006 - 12.36

gandalf_03_75 Profilo | Junior Member

Ciao a tutti nn dite che sono uno scassa er favore ma ho un altro problema.
Ho un gridview che viene caricato tramite la chiamata ad una stored procedure (sp_ListaDVD) a cui passo un parametro "@IdGenere".
Ho realizzato questa sub ma quando fa il fill del dataset va in errore.

----------------------------------------------------------------------------------------------------------------------
Public class Connect
----------------------------------------------------------------------------------------------------------------------
public DataSet GetDataset(string strSQL)
{
SqlCommand command = new SqlCommand();
//SqlDataAdapter da = new SqlDataAdapter(strSQL, Cn);
DataSet Ds = new DataSet();
string msg;
try {

if (param.Count > 0)
{
int I;
int y;
y = param.Count - 1;
try{
for(I=0;I<=y;I++)
{
command.Parameters.Add(param[I].ParameterName, param [I].SqlDbType).Value = param[I].Value;
command.Parameters[I].Direction = param[I].Direction;
}
}
catch (System.Exception e) { msg = e.Message.ToUpper(); }
command.Connection=Cn;
command.CommandText = strSQL;
SqlDataAdapter da = new SqlDataAdapter(command);
da.Fill(Ds);
}
}
catch (System.Exception e)

{
msg = e.Message.ToUpper();
}

//finally

// {
// Ds.Dispose();
// da.Dispose();
// }
return Ds;
}

---------------------------------------------------------------------------------------------------------------------

Chiamata alla sub

-------------------------------------------------------------------

private void BindData()
{
Connect cn = new Connect();
cn.OpenConnection();
cn.param.AddWithValue("@IdGenere", 1);
DataSet ds;
ds = cn.GetDataset("sp_ListaDvd");
grdvDVD.DataSource = ds;
grdvDVD.DataBind();
}

-------------------------------------------------------------------

C'e' qualcosa che nn va in questo codice??
Nn riesco a capire

Grazie a tutti
Per i paurosi il futuro resterà sconosciuto, per i deboli sarà irraggiungibile, per gli incoscienti offrirà nuove opportunità.
Partecipa anche tu! Registrati!
Hai bisogno di aiuto ?
Perchè non ti registri subito?

Dopo esserti registrato potrai chiedere
aiuto sul nostro Forum oppure aiutare gli altri

Consulta le Stanze disponibili.

Registrati ora !
Copyright © dotNetHell.it 2002-2024
Running on Windows Server 2008 R2 Standard, SQL Server 2012 & ASP.NET 3.5