I am constantly receiving the "Object reference not set to
an instance of an object" Exception when I try to set the
autoincrement to true. I found the Knowledge Base Article
819346 which seems to address the error message, but how
do I know that this is what is causing the problem..? If
this is the route I must take, is the only fix for this is
to upgrade to .Net 2003???

Here is the line of code I am receiving error on:

Dim IdCol As String = "type_id"
Dim ParentTable As String = "PgmTypes"

'Error occurs here
Ds1.Tables(ParentTable).Columns(IdCol).AutoIncrement = True
Ds1.Tables(ParentTable).Columns(IdCol).AutoIncrementSeed
= -1
Ds1.Tables(ParentTable).Columns(IdCol).AutoIncrementStep
= -1
Ds1.Tables(ParentTable).PrimaryKey = New Object()
{Ds1.Tables(ParentTable).Columns(0)}


sqlDataAdp.Fill(Ds1, ParentTable)
uwGrid.DataSource = Ds1
uwGrid.DataMember = ParentTable
'Set the datakeyfield for the row.datakey property
population
uwGrid.Bands(0).DataKeyField = IdCol
uwGrid.DataBind()

Any help would be great,
Thanks.

Re: Object reference not set to an instance of an object by One

One
Sun Aug 17 04:22:48 CDT 2003


I assume you have previously created DS1 ? and that the parent table and
column actually exists ?
try putting in some code and use debug.writeline to send all tables and
column names to your output window at least this will confirm their
existance

HTH

Here is the line of code I am receiving error on:

Dim IdCol As String = "type_id"
Dim ParentTable As String = "PgmTypes"

'Error occurs here
Ds1.Tables(ParentTable).Columns(IdCol).AutoIncrement = True
Ds1.Tables(ParentTable).Columns(IdCol).AutoIncrementSeed
= -1
Ds1.Tables(ParentTable).Columns(IdCol).AutoIncrementStep
= -1

"Dianna K" <dkampe@cbs.com> wrote in message
news:022701c36434$875caaa0$a301280a@phx.gbl...
> I am constantly receiving the "Object reference not set to
> an instance of an object" Exception when I try to set the
> autoincrement to true. I found the Knowledge Base Article
> 819346 which seems to address the error message, but how
> do I know that this is what is causing the problem..? If
> this is the route I must take, is the only fix for this is
> to upgrade to .Net 2003???
>
> Here is the line of code I am receiving error on:
>
> Dim IdCol As String = "type_id"
> Dim ParentTable As String = "PgmTypes"
>
> 'Error occurs here
> Ds1.Tables(ParentTable).Columns(IdCol).AutoIncrement = True
> Ds1.Tables(ParentTable).Columns(IdCol).AutoIncrementSeed
> = -1
> Ds1.Tables(ParentTable).Columns(IdCol).AutoIncrementStep
> = -1
> Ds1.Tables(ParentTable).PrimaryKey = New Object()
> {Ds1.Tables(ParentTable).Columns(0)}
>
>
> sqlDataAdp.Fill(Ds1, ParentTable)
> uwGrid.DataSource = Ds1
> uwGrid.DataMember = ParentTable
> 'Set the datakeyfield for the row.datakey property
> population
> uwGrid.Bands(0).DataKeyField = IdCol
> uwGrid.DataBind()
>
> Any help would be great,
> Thanks.



Re: Object reference not set to an instance of an object by Dianna

Dianna
Sun Aug 17 13:01:16 CDT 2003

Hi HTH,

I threw in some debug code and it looks like the dataset
is good:

If Ds1 Is Nothing Then
lblError.Text = lblError.Text + "dataset is nothing"
Exit Sub
End If

Ds1.Tables(ParentTable).Columns(IdCol).AutoIncrement = True

This code is for a grid. Originally I created the dataset
via the SQLDataAdapter 'wizard'. The above code worked
fine. The above error started when I changed the code to
create the dataset programatically...? I know the data is
binding (I can see the records when the page first
loads). It incurs the error upon the update.
Dianna

>-----Original Message-----
>
>I assume you have previously created DS1 ? and that the
parent table and
>column actually exists ?
>try putting in some code and use debug.writeline to send
all tables and
>column names to your output window at least this will
confirm their
>existance
>
>HTH
>
>Here is the line of code I am receiving error on:
>
>Dim IdCol As String = "type_id"
>Dim ParentTable As String = "PgmTypes"
>
>'Error occurs here
>Ds1.Tables(ParentTable).Columns(IdCol).AutoIncrement =
True
>Ds1.Tables(ParentTable).Columns(IdCol).AutoIncrementSeed
>= -1
>Ds1.Tables(ParentTable).Columns(IdCol).AutoIncrementStep
>= -1
>
>"Dianna K" <dkampe@cbs.com> wrote in message
>news:022701c36434$875caaa0$a301280a@phx.gbl...
>> I am constantly receiving the "Object reference not set
to
>> an instance of an object" Exception when I try to set
the
>> autoincrement to true. I found the Knowledge Base
Article
>> 819346 which seems to address the error message, but how
>> do I know that this is what is causing the problem..?
If
>> this is the route I must take, is the only fix for this
is
>> to upgrade to .Net 2003???
>>
>> Here is the line of code I am receiving error on:
>>
>> Dim IdCol As String = "type_id"
>> Dim ParentTable As String = "PgmTypes"
>>
>> 'Error occurs here
>> Ds1.Tables(ParentTable).Columns(IdCol).AutoIncrement =
True
>> Ds1.Tables(ParentTable).Columns(IdCol).AutoIncrementSeed
>> = -1
>> Ds1.Tables(ParentTable).Columns(IdCol).AutoIncrementStep
>> = -1
>> Ds1.Tables(ParentTable).PrimaryKey = New Object()
>> {Ds1.Tables(ParentTable).Columns(0)}
>>
>>
>> sqlDataAdp.Fill(Ds1, ParentTable)
>> uwGrid.DataSource = Ds1
>> uwGrid.DataMember = ParentTable
>> 'Set the datakeyfield for the row.datakey
property
>> population
>> uwGrid.Bands(0).DataKeyField = IdCol
>> uwGrid.DataBind()
>>
>> Any help would be great,
>> Thanks.
>
>
>.
>

Object reference not set to an instance of an object by William

William
Sun Aug 17 18:14:13 CDT 2003

Diana:

From your last post, are you getting the whole way
through this code? Where is it located? Does it fail
when you initialize the dataset/datatables or when you
submit an Update?

Another possible problem if it's failing as stated below
is a possible misspelling of table or column names. Try
numeric indexes instead of named fields. It's good
practice anyway b/c if you use numeric indexes instead of
names, the Datatable doesn't need to resolve column names
each time it reads a row. If nothing else, you may want
to consider using GetOrdinal so that you can still use
your names while getting the performance benefit of
numerics. Anyway, I digress, performance isn't the
problem.


If you declare ds as a DataSet but never make a new one
or don't have a scoped object that's been created, this
could cause it but I doubt it b /c you'd probably get a
syntax error.

If you don't mind, can you post the whole code snippet so
I can see what event this is called from?

I can probably be more help then.

Good Luck,

Bill

W.G. Ryan
dotnetguru@comast.nospam.net
www.knowdotnet.com
>-----Original Message-----
>I am constantly receiving the "Object reference not set
to
>an instance of an object" Exception when I try to set
the
>autoincrement to true. I found the Knowledge Base
Article
>819346 which seems to address the error message, but how
>do I know that this is what is causing the problem..?
If
>this is the route I must take, is the only fix for this
is
>to upgrade to .Net 2003???
>
>Here is the line of code I am receiving error on:
>
>Dim IdCol As String = "type_id"
>Dim ParentTable As String = "PgmTypes"
>
>'Error occurs here
>Ds1.Tables(ParentTable).Columns(IdCol).AutoIncrement =
True
>Ds1.Tables(ParentTable).Columns(IdCol).AutoIncrementSeed
>= -1
>Ds1.Tables(ParentTable).Columns(IdCol).AutoIncrementStep
>= -1
>Ds1.Tables(ParentTable).PrimaryKey = New Object()
>{Ds1.Tables(ParentTable).Columns(0)}
>
>
> sqlDataAdp.Fill(Ds1, ParentTable)
> uwGrid.DataSource = Ds1
> uwGrid.DataMember = ParentTable
> 'Set the datakeyfield for the row.datakey
property
>population
> uwGrid.Bands(0).DataKeyField = IdCol
> uwGrid.DataBind()
>
>Any help would be great,
>Thanks.
>.
>