The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

import-bot (20211) [Avatar] Offline
#1
Re: Error Running Listing 16.2
[Originally posted by codedude]

Hi Arlen,

One last note, this appears to be a problem with listing 16.3 also.

Thanks,
Mike

> Arlen,
>
> It appears that the reason this is failing is because when the ADONetSamples
> database was setup on my server with the Utility program that you have
> provided, the ClassID field is setup to not allow nulls, and listing 16.2
> supplies no value for this field when inserting the new record in the dataset.
> Please verify this and let me know if I am missing something else.
>
> Thanks,
> Mike
>
> > Hi Arlen,
> >
> > I'm getting an error running example listing 16.2. I have the code exactly
as
> > you have in your sample, using the same clients (using SQL Server 2000
> > evaluation edition) and I receive the following exception when calling the
> > Update method on the SQLDataAdapter object: "Dynamic SQL generation for the
> > UpdateCommand is not supported against a SelectCommand that does not return
> > any key column information." Do you have any idea as to why I'm receiving
this
> > error? If so, please let me know of what I may do to resolve this error.
> >
> > Thanks,
> > Mike
import-bot (20211) [Avatar] Offline
#2
Re: Error Running Listing 16.2
[Originally posted by arlen]


Hmm - the ClassID field should be automatically filled in - it is an
AutoIncrement field (or should be - it is possible that the setup utility is
not setting the field up correctly).

Can you go into Enterprise Manager, right-click on the Classes table and
choose Design, highlight the ClassID field and look at the list of properties
at the bototm. You should see the following values:

Identity: Yes
Identity Seed: 1
Identity Increment: 1

You should also make sure that the field is marked as the primary key for the
table - it should have a little key next to the row. . .


> Hi Arlen,
>
> One last note, this appears to be a problem with listing 16.3 also.
>
> Thanks,
> Mike
>
> > Arlen,
> >
> > It appears that the reason this is failing is because when the ADONetSamples
> > database was setup on my server with the Utility program that you have
> > provided, the ClassID field is setup to not allow nulls, and listing 16.2
> > supplies no value for this field when inserting the new record in the
dataset.
> > Please verify this and let me know if I am missing something else.
> >
> > Thanks,
> > Mike
> >
> > > Hi Arlen,
> > >
> > > I'm getting an error running example listing 16.2. I have the code exactly
> as
> > > you have in your sample, using the same clients (using SQL Server 2000
> > > evaluation edition) and I receive the following exception when calling the
> > > Update method on the SQLDataAdapter object: "Dynamic SQL generation for
the
> > > UpdateCommand is not supported against a SelectCommand that does not
return
> > > any key column information." Do you have any idea as to why I'm receiving
> this
> > > error? If so, please let me know of what I may do to resolve this error.
> > >
> > > Thanks,
> > > Mike
import-bot (20211) [Avatar] Offline
#3
Re: Error Running Listing 16.2
[Originally posted by codedude]

The Identity and Identity Seed are set as you have mentioned, yet the field
was not listed as the Primary Key as you have guessed. Yet when running the
code now, I get a message that the ClassID field will not except a null value
exception.

In the code listing, after the Primary Key object has been added to the
DataSet object, I have added the following line of code:

dt.Columns["ClassID"].AutoIncrement = true;

Now when I compile and run the sample it seems to work correctly. Please let
me know what you think.

Thanks,
Mike

>
> Hmm - the ClassID field should be automatically filled in - it is an
> AutoIncrement field (or should be - it is possible that the setup utility is
> not setting the field up correctly).
>
> Can you go into Enterprise Manager, right-click on the Classes table and
> choose Design, highlight the ClassID field and look at the list of properties
> at the bototm. You should see the following values:
>
> Identity: Yes
> Identity Seed: 1
> Identity Increment: 1
>
> You should also make sure that the field is marked as the primary key for the
> table - it should have a little key next to the row. . .
>
>
> > Hi Arlen,
> >
> > One last note, this appears to be a problem with listing 16.3 also.
> >
> > Thanks,
> > Mike
> >
> > > Arlen,
> > >
> > > It appears that the reason this is failing is because when the
ADONetSamples
> > > database was setup on my server with the Utility program that you have
> > > provided, the ClassID field is setup to not allow nulls, and listing 16.2
> > > supplies no value for this field when inserting the new record in the
> dataset.
> > > Please verify this and let me know if I am missing something else.
> > >
> > > Thanks,
> > > Mike
> > >
> > > > Hi Arlen,
> > > >
> > > > I'm getting an error running example listing 16.2. I have the code
exactly
> > as
> > > > you have in your sample, using the same clients (using SQL Server 2000
> > > > evaluation edition) and I receive the following exception when calling
the
> > > > Update method on the SQLDataAdapter object: "Dynamic SQL generation for
> the
> > > > UpdateCommand is not supported against a SelectCommand that does not
> return
> > > > any key column information." Do you have any idea as to why I'm
receiving
> > this
> > > > error? If so, please let me know of what I may do to resolve this
error.
> > > >
> > > > Thanks,
> > > > Mike
import-bot (20211) [Avatar] Offline
#4
Re: Error Running Listing 16.2
[Originally posted by arlen]

Oops - yes, sorry. Apparently this was something that I fixed in the
downloadable code, but was an error in the book - even though it will be
overwritten, there has to be a value in the ClassID column.

The solution you found (setting it as AutoIncrement) will work, as it will put
a value in the field. The way I changed the downloadable version of the code
is to just put a value in the field - here is what that version of the code
looks like:

// Add a row
DataRow drNew = dt.NewRow();
drNew["TeacherID"] = 2;
drNew["ClassName"] = "Philosophy";
drNew["Period"] = 5;
drNew["ClassID"] = -1; // Cannot be null, but database will reassign
dt.Rows.Add(drNew);
PrintDataTable("After making changes",ds.Tables["Classes"]);

I _really_ did test all of the code snippets in the book, but with beta
version of .NET. Originally this did not throw an exception. Apparently I
realized the change when I was preparing the code for download, but forgot to
make a note. At some point I will put up an errata list.

Thanks for catching this,

Arlen
import-bot (20211) [Avatar] Offline
#5
[Originally posted by codedude]

Hi Arlen,

I'm getting an error running example listing 16.2. I have the code exactly as
you have in your sample, using the same clients (using SQL Server 2000
evaluation edition) and I receive the following exception when calling the
Update method on the SQLDataAdapter object: "Dynamic SQL generation for the
UpdateCommand is not supported against a SelectCommand that does not return
any key column information." Do you have any idea as to why I'm receiving this
error? If so, please let me know of what I may do to resolve this error.

Thanks,
Mike
import-bot (20211) [Avatar] Offline
#6
Re: Error Running Listing 16.2
[Originally posted by codedude]

Thanks for the help Arlen! smilie This is an excellent book I must say. I've
already learned so much about ADO.Net just getting this far! And I must say
that this book is making it a joy to learn.

Thanks again!
Mike smilie
import-bot (20211) [Avatar] Offline
#7
Re: Error Running Listing 16.2
[Originally posted by codedude]

Arlen,

It appears that the reason this is failing is because when the ADONetSamples
database was setup on my server with the Utility program that you have
provided, the ClassID field is setup to not allow nulls, and listing 16.2
supplies no value for this field when inserting the new record in the dataset.
Please verify this and let me know if I am missing something else.

Thanks,
Mike

> Hi Arlen,
>
> I'm getting an error running example listing 16.2. I have the code exactly as
> you have in your sample, using the same clients (using SQL Server 2000
> evaluation edition) and I receive the following exception when calling the
> Update method on the SQLDataAdapter object: "Dynamic SQL generation for the
> UpdateCommand is not supported against a SelectCommand that does not return
> any key column information." Do you have any idea as to why I'm receiving this
> error? If so, please let me know of what I may do to resolve this error.
>
> Thanks,
> Mike