Hello I'm trying to edit my klientTableAdapter.CommanText
which is TableAdapter
in dynamically created DataSet
called DSSchema
- this was dynamically created when creating report using ReportViewer
.
string sqlcomEvent = "SELECT akce,name,surname,rodcis,(Cast([street] as nvarchar(MAX)) + ', '+ city + ', ' + ZIP) AS Adresa, odjezd, sitting, rocnik FROM dbo.klient WHERE (event=@event";
for (int a = 0; a < CommonEvents.Count(); a++)
{
sqlcomEvent += " OR event='" + CommonEvents[a]+"'";
}
sqlcomEvent += " )AND year=@year ORDER BY SITTING";
// TODO: This line of code loads data into the 'dtourDataSet.klient' table. You can move, or remove it, as needed.
this.klientTableAdapter.Adapter.SelectCommand.CommandText = sqlcomEvent ;
this.klientTableAdapter.Fill(this.dtourDataSet.klient,zajezd,klientClass.Rocnik());
this.reportViewer1.RefreshReport();
I believe the NullReferenceException
is raised because I havent declared klientTableAdapter before, but when I add this line var klientTableAdapter = new klientTableAdapter();
I get error:
tours.TiskSchemaDoprava.klientTableAdapter is a field; but is used like a type
Would anyone please help me solve this out ?
This works perfectly for me but Iam not sure if there isn't smarter way to do so?
this.klientTableAdapter.Fill(this.dtourDataSet.klient,zajezd,klientClass.Rocnik());
this.klientTableAdapter.Adapter.SelectCommand.CommandText = sqlcomZaj;
this.klientTableAdapter.Fill(this.dtourDataSet.klient, zajezd, klientClass.Rocnik());
this.reportViewer1.RefreshReport();