Hello,

I created a dataset and dataTable in the designer (VB2005) as the datasource
for a Reportviewer control. Up to now I have been creating
dataTables/datasets/dataAdapters on the fly at runtime. But I need to set
field properties on the reportviewer at design time - could probably do it at
run time - but too much code.

So at run time I do this to fill a datatable on the fly
dim da As new sqldataAdapter
dim ds as new dataset
da.selectcommand = new sqlcommand
da.selectcommand.connection = conn
da.selectcommand.commantext = "select * from tbl1")
da.Fill(ds, "tblx")

Now my dataset exists at design time along with the datatable. How do I
fill the existing datatable? the runtime code above complains if I reference
the dataset/dataTable I created at design time. Any suggestions appreciated.

Thanks,
Rich

Re: ?fill dataTable created at design time with dataAdpter at runtime by Cor

Cor
Mon Oct 02 23:27:40 CDT 2006

Rich,

Why do you not use the generated dataset

dim ds as DirectCast(GeneratedDataset as DataSet)

Cor

"Rich" <Rich@discussions.microsoft.com> schreef in bericht
news:396815C5-2939-4EDA-AAE3-AFE27B9853EA@microsoft.com...
> Hello,
>
> I created a dataset and dataTable in the designer (VB2005) as the
> datasource
> for a Reportviewer control. Up to now I have been creating
> dataTables/datasets/dataAdapters on the fly at runtime. But I need to set
> field properties on the reportviewer at design time - could probably do it
> at
> run time - but too much code.
>
> So at run time I do this to fill a datatable on the fly
> dim da As new sqldataAdapter
> dim ds as new dataset
> da.selectcommand = new sqlcommand
> da.selectcommand.connection = conn
> da.selectcommand.commantext = "select * from tbl1")
> da.Fill(ds, "tblx")
>
> Now my dataset exists at design time along with the datatable. How do I
> fill the existing datatable? the runtime code above complains if I
> reference
> the dataset/dataTable I created at design time. Any suggestions
> appreciated.
>
> Thanks,
> Rich



Re: ?fill dataTable created at design time with dataAdpter at runt by Rich

Rich
Tue Oct 03 00:37:01 CDT 2006

Thanks. I don't understand the idea of using the generated dataset. I tried

Dim ds As DirectCast(GeneratedDataset As Dataset)

but VS complained. So I tried:

Dim ds As DirectCast(Dataset1 As Dataset '--where Dataset1 is the name of
the dataset.

But VS complained about that also. May I request if you could explain in a
little bit more detail about using the generated dataset as you suggest?

Thanks,
Rich

"Cor Ligthert [MVP]" wrote:

> Rich,
>
> Why do you not use the generated dataset
>
> dim ds as DirectCast(GeneratedDataset as DataSet)
>
> Cor
>
> "Rich" <Rich@discussions.microsoft.com> schreef in bericht
> news:396815C5-2939-4EDA-AAE3-AFE27B9853EA@microsoft.com...
> > Hello,
> >
> > I created a dataset and dataTable in the designer (VB2005) as the
> > datasource
> > for a Reportviewer control. Up to now I have been creating
> > dataTables/datasets/dataAdapters on the fly at runtime. But I need to set
> > field properties on the reportviewer at design time - could probably do it
> > at
> > run time - but too much code.
> >
> > So at run time I do this to fill a datatable on the fly
> > dim da As new sqldataAdapter
> > dim ds as new dataset
> > da.selectcommand = new sqlcommand
> > da.selectcommand.connection = conn
> > da.selectcommand.commantext = "select * from tbl1")
> > da.Fill(ds, "tblx")
> >
> > Now my dataset exists at design time along with the datatable. How do I
> > fill the existing datatable? the runtime code above complains if I
> > reference
> > the dataset/dataTable I created at design time. Any suggestions
> > appreciated.
> >
> > Thanks,
> > Rich
>
>
>

Re: ?fill dataTable created at design time with dataAdpter at runt by Cor

Cor
Tue Oct 03 00:50:58 CDT 2006

Rich,

What version are you using?

Be aware that I cannot answer you after this before the evening here.

If it is 2003 you have probably somewhere

dim dataset11 as new dataset1 (the generated class you see in your solution
explorer if you open in top show all files)

Than you can use AFAIK that dataset as

dim ds as Dataset = directcast(dataset11, DataSet)

Cor

"Rich" <Rich@discussions.microsoft.com> schreef in bericht
news:9F1AC648-BD6A-44C5-8C8E-CBBCA6D2BE59@microsoft.com...
> Thanks. I don't understand the idea of using the generated dataset. I
> tried
>
> Dim ds As DirectCast(GeneratedDataset As Dataset)
>
> but VS complained. So I tried:
>
> Dim ds As DirectCast(Dataset1 As Dataset '--where Dataset1 is the name of
> the dataset.
>
> But VS complained about that also. May I request if you could explain in
> a
> little bit more detail about using the generated dataset as you suggest?
>
> Thanks,
> Rich
>
> "Cor Ligthert [MVP]" wrote:
>
>> Rich,
>>
>> Why do you not use the generated dataset
>>
>> dim ds as DirectCast(GeneratedDataset as DataSet)
>>
>> Cor
>>
>> "Rich" <Rich@discussions.microsoft.com> schreef in bericht
>> news:396815C5-2939-4EDA-AAE3-AFE27B9853EA@microsoft.com...
>> > Hello,
>> >
>> > I created a dataset and dataTable in the designer (VB2005) as the
>> > datasource
>> > for a Reportviewer control. Up to now I have been creating
>> > dataTables/datasets/dataAdapters on the fly at runtime. But I need to
>> > set
>> > field properties on the reportviewer at design time - could probably do
>> > it
>> > at
>> > run time - but too much code.
>> >
>> > So at run time I do this to fill a datatable on the fly
>> > dim da As new sqldataAdapter
>> > dim ds as new dataset
>> > da.selectcommand = new sqlcommand
>> > da.selectcommand.connection = conn
>> > da.selectcommand.commantext = "select * from tbl1")
>> > da.Fill(ds, "tblx")
>> >
>> > Now my dataset exists at design time along with the datatable. How do
>> > I
>> > fill the existing datatable? the runtime code above complains if I
>> > reference
>> > the dataset/dataTable I created at design time. Any suggestions
>> > appreciated.
>> >
>> > Thanks,
>> > Rich
>>
>>
>>



Re: ?fill dataTable created at design time with dataAdpter at runtime by Miha

Miha
Tue Oct 03 01:45:16 CDT 2006

Hi Rich,

What and where exactly is the error?

--
Miha Markic [MVP C#, INETA Country Leader for Slovenia]
RightHand .NET consulting & development www.rthand.com
Blog: http://cs.rthand.com/blogs/blog_with_righthand/

"Rich" <Rich@discussions.microsoft.com> wrote in message
news:396815C5-2939-4EDA-AAE3-AFE27B9853EA@microsoft.com...
> Hello,
>
> I created a dataset and dataTable in the designer (VB2005) as the
> datasource
> for a Reportviewer control. Up to now I have been creating
> dataTables/datasets/dataAdapters on the fly at runtime. But I need to set
> field properties on the reportviewer at design time - could probably do it
> at
> run time - but too much code.
>
> So at run time I do this to fill a datatable on the fly
> dim da As new sqldataAdapter
> dim ds as new dataset
> da.selectcommand = new sqlcommand
> da.selectcommand.connection = conn
> da.selectcommand.commantext = "select * from tbl1")
> da.Fill(ds, "tblx")
>
> Now my dataset exists at design time along with the datatable. How do I
> fill the existing datatable? the runtime code above complains if I
> reference
> the dataset/dataTable I created at design time. Any suggestions
> appreciated.
>
> Thanks,
> Rich



RE: ?fill dataTable created at design time with dataAdpter at runtime by Rich

Rich
Tue Oct 03 10:20:02 CDT 2006

Thank you all for your replies. I am using VB2005.

I create a dataset manually, so in the solution explorer I have
Dataset1.xsd. In the Datasources tab I have my Dataset1 and I add a table
from the toolbox and add the columns manually - this way I can create an rdlc
file for the Report viewer based on the persistent table. But I want to fill
this table using a programmatic dataAdapter - not a TableAdapter from the
toolbox. If I do this:

Dim da As New sqlDataAdpater
Dim ds As DirectCast(Dataset1 As Dataset)

I get the blue squiggly line under DirectCast. I have tried different
variations of

Dim ds As MyProjectName.Dataset1

But VisualStudio(2005) complains. Do I need to use a Namespace maybe? It
seems like the form where I am trying to access Dataset1 just can't see it.
So the question could be - how to make dataset1.xsd visible to my
form/application?

Thanks,
Rich

"Rich" wrote:

> Hello,
>
> I created a dataset and dataTable in the designer (VB2005) as the datasource
> for a Reportviewer control. Up to now I have been creating
> dataTables/datasets/dataAdapters on the fly at runtime. But I need to set
> field properties on the reportviewer at design time - could probably do it at
> run time - but too much code.
>
> So at run time I do this to fill a datatable on the fly
> dim da As new sqldataAdapter
> dim ds as new dataset
> da.selectcommand = new sqlcommand
> da.selectcommand.connection = conn
> da.selectcommand.commantext = "select * from tbl1")
> da.Fill(ds, "tblx")
>
> Now my dataset exists at design time along with the datatable. How do I
> fill the existing datatable? the runtime code above complains if I reference
> the dataset/dataTable I created at design time. Any suggestions appreciated.
>
> Thanks,
> Rich

RE: ?fill dataTable created at design time with dataAdpter at runt by Rich

Rich
Tue Oct 03 11:29:01 CDT 2006

here is some syntax that I tried (which is probably the syntax Cor was
pointing me to)

Dim ds As New Dataset1

Now VS does not complain - although now I have a new issue - which is that I
need the rdlc file to see the dataset in the designer. I will figure that
one out myself.

"Rich" wrote:

> Thank you all for your replies. I am using VB2005.
>
> I create a dataset manually, so in the solution explorer I have
> Dataset1.xsd. In the Datasources tab I have my Dataset1 and I add a table
> from the toolbox and add the columns manually - this way I can create an rdlc
> file for the Report viewer based on the persistent table. But I want to fill
> this table using a programmatic dataAdapter - not a TableAdapter from the
> toolbox. If I do this:
>
> Dim da As New sqlDataAdpater
> Dim ds As DirectCast(Dataset1 As Dataset)
>
> I get the blue squiggly line under DirectCast. I have tried different
> variations of
>
> Dim ds As MyProjectName.Dataset1
>
> But VisualStudio(2005) complains. Do I need to use a Namespace maybe? It
> seems like the form where I am trying to access Dataset1 just can't see it.
> So the question could be - how to make dataset1.xsd visible to my
> form/application?
>
> Thanks,
> Rich
>
> "Rich" wrote:
>
> > Hello,
> >
> > I created a dataset and dataTable in the designer (VB2005) as the datasource
> > for a Reportviewer control. Up to now I have been creating
> > dataTables/datasets/dataAdapters on the fly at runtime. But I need to set
> > field properties on the reportviewer at design time - could probably do it at
> > run time - but too much code.
> >
> > So at run time I do this to fill a datatable on the fly
> > dim da As new sqldataAdapter
> > dim ds as new dataset
> > da.selectcommand = new sqlcommand
> > da.selectcommand.connection = conn
> > da.selectcommand.commantext = "select * from tbl1")
> > da.Fill(ds, "tblx")
> >
> > Now my dataset exists at design time along with the datatable. How do I
> > fill the existing datatable? the runtime code above complains if I reference
> > the dataset/dataTable I created at design time. Any suggestions appreciated.
> >
> > Thanks,
> > Rich

Re: ?fill dataTable created at design time with dataAdpter at runtime by Cor

Cor
Tue Oct 03 11:37:20 CDT 2006

Rich,

I don't know if this is the error,

Dim ds As Dataset = DirectCast(Dataset1,Dataset)

But this is for sure more the code that is with the directcast

Cor

"Rich" <Rich@discussions.microsoft.com> schreef in bericht
news:6862FFF0-4DE3-4AA0-BA71-C48F5F723761@microsoft.com...
> Thank you all for your replies. I am using VB2005.
>
> I create a dataset manually, so in the solution explorer I have
> Dataset1.xsd. In the Datasources tab I have my Dataset1 and I add a table
> from the toolbox and add the columns manually - this way I can create an
> rdlc
> file for the Report viewer based on the persistent table. But I want to
> fill
> this table using a programmatic dataAdapter - not a TableAdapter from the
> toolbox. If I do this:
>
> Dim da As New sqlDataAdpater
> Dim ds As DirectCast(Dataset1 As Dataset)
>
> I get the blue squiggly line under DirectCast. I have tried different
> variations of
>
> Dim ds As MyProjectName.Dataset1
>
> But VisualStudio(2005) complains. Do I need to use a Namespace maybe? It
> seems like the form where I am trying to access Dataset1 just can't see
> it.
> So the question could be - how to make dataset1.xsd visible to my
> form/application?
>
> Thanks,
> Rich
>
> "Rich" wrote:
>
>> Hello,
>>
>> I created a dataset and dataTable in the designer (VB2005) as the
>> datasource
>> for a Reportviewer control. Up to now I have been creating
>> dataTables/datasets/dataAdapters on the fly at runtime. But I need to
>> set
>> field properties on the reportviewer at design time - could probably do
>> it at
>> run time - but too much code.
>>
>> So at run time I do this to fill a datatable on the fly
>> dim da As new sqldataAdapter
>> dim ds as new dataset
>> da.selectcommand = new sqlcommand
>> da.selectcommand.connection = conn
>> da.selectcommand.commantext = "select * from tbl1")
>> da.Fill(ds, "tblx")
>>
>> Now my dataset exists at design time along with the datatable. How do I
>> fill the existing datatable? the runtime code above complains if I
>> reference
>> the dataset/dataTable I created at design time. Any suggestions
>> appreciated.
>>
>> Thanks,
>> Rich



Re: ?fill dataTable created at design time with dataAdpter at runt by Rich

Rich
Tue Oct 03 16:43:02 CDT 2006

Hi Cor,

Thanks for getting back to me. I keep getting complaints from VS with
dim ds as dataset = directcast(dataset1, dataset)

but if I say

dim ds as new dataset1, then VS does not complain, and I can see the
datatable1 from ds.DataTable1. Also, the report rdcl file appears to work
satisfactory with

report.LocalReport.DataSources.Add(New ResportDataSource("myscr",
ds.datatable1)

I thank you very much for your input as it guided me to what appears to be
the solution.

Rich


"Cor Ligthert [MVP]" wrote:

> Rich,
>
> I don't know if this is the error,
>
> Dim ds As Dataset = DirectCast(Dataset1,Dataset)
>
> But this is for sure more the code that is with the directcast
>
> Cor
>
> "Rich" <Rich@discussions.microsoft.com> schreef in bericht
> news:6862FFF0-4DE3-4AA0-BA71-C48F5F723761@microsoft.com...
> > Thank you all for your replies. I am using VB2005.
> >
> > I create a dataset manually, so in the solution explorer I have
> > Dataset1.xsd. In the Datasources tab I have my Dataset1 and I add a table
> > from the toolbox and add the columns manually - this way I can create an
> > rdlc
> > file for the Report viewer based on the persistent table. But I want to
> > fill
> > this table using a programmatic dataAdapter - not a TableAdapter from the
> > toolbox. If I do this:
> >
> > Dim da As New sqlDataAdpater
> > Dim ds As DirectCast(Dataset1 As Dataset)
> >
> > I get the blue squiggly line under DirectCast. I have tried different
> > variations of
> >
> > Dim ds As MyProjectName.Dataset1
> >
> > But VisualStudio(2005) complains. Do I need to use a Namespace maybe? It
> > seems like the form where I am trying to access Dataset1 just can't see
> > it.
> > So the question could be - how to make dataset1.xsd visible to my
> > form/application?
> >
> > Thanks,
> > Rich
> >
> > "Rich" wrote:
> >
> >> Hello,
> >>
> >> I created a dataset and dataTable in the designer (VB2005) as the
> >> datasource
> >> for a Reportviewer control. Up to now I have been creating
> >> dataTables/datasets/dataAdapters on the fly at runtime. But I need to
> >> set
> >> field properties on the reportviewer at design time - could probably do
> >> it at
> >> run time - but too much code.
> >>
> >> So at run time I do this to fill a datatable on the fly
> >> dim da As new sqldataAdapter
> >> dim ds as new dataset
> >> da.selectcommand = new sqlcommand
> >> da.selectcommand.connection = conn
> >> da.selectcommand.commantext = "select * from tbl1")
> >> da.Fill(ds, "tblx")
> >>
> >> Now my dataset exists at design time along with the datatable. How do I
> >> fill the existing datatable? the runtime code above complains if I
> >> reference
> >> the dataset/dataTable I created at design time. Any suggestions
> >> appreciated.
> >>
> >> Thanks,
> >> Rich
>
>
>

Re: ?fill dataTable created at design time with dataAdpter at runtime by Miha

Miha
Wed Oct 04 03:53:46 CDT 2006

Rich,

You don't need to downcast from strongtyped dataset to generic one.
My guess is that you are using type while you should use an instance of that
dataset...

--
Miha Markic [MVP C#, INETA Country Leader for Slovenia]
RightHand .NET consulting & development www.rthand.com
Blog: http://cs.rthand.com/blogs/blog_with_righthand/

"Rich" <Rich@discussions.microsoft.com> wrote in message
news:6862FFF0-4DE3-4AA0-BA71-C48F5F723761@microsoft.com...
> Thank you all for your replies. I am using VB2005.
>
> I create a dataset manually, so in the solution explorer I have
> Dataset1.xsd. In the Datasources tab I have my Dataset1 and I add a table
> from the toolbox and add the columns manually - this way I can create an
> rdlc
> file for the Report viewer based on the persistent table. But I want to
> fill
> this table using a programmatic dataAdapter - not a TableAdapter from the
> toolbox. If I do this:
>
> Dim da As New sqlDataAdpater
> Dim ds As DirectCast(Dataset1 As Dataset)
>
> I get the blue squiggly line under DirectCast. I have tried different
> variations of
>
> Dim ds As MyProjectName.Dataset1
>
> But VisualStudio(2005) complains. Do I need to use a Namespace maybe? It
> seems like the form where I am trying to access Dataset1 just can't see
> it.
> So the question could be - how to make dataset1.xsd visible to my
> form/application?
>
> Thanks,
> Rich
>
> "Rich" wrote:
>
>> Hello,
>>
>> I created a dataset and dataTable in the designer (VB2005) as the
>> datasource
>> for a Reportviewer control. Up to now I have been creating
>> dataTables/datasets/dataAdapters on the fly at runtime. But I need to
>> set
>> field properties on the reportviewer at design time - could probably do
>> it at
>> run time - but too much code.
>>
>> So at run time I do this to fill a datatable on the fly
>> dim da As new sqldataAdapter
>> dim ds as new dataset
>> da.selectcommand = new sqlcommand
>> da.selectcommand.connection = conn
>> da.selectcommand.commantext = "select * from tbl1")
>> da.Fill(ds, "tblx")
>>
>> Now my dataset exists at design time along with the datatable. How do I
>> fill the existing datatable? the runtime code above complains if I
>> reference
>> the dataset/dataTable I created at design time. Any suggestions
>> appreciated.
>>
>> Thanks,
>> Rich