Connecting Tech Pros Worldwide Forums | Help | Site Map

Need some help with this code...

EMW
Guest
 
Posts: n/a
#1: Nov 20 '05
Hi,

Can someone please look at this code and tell me why I get an exception
error on the last line:

For aa = 0 To ds.Tables(0).Columns.Count - 1
dbColumn = New SQLDMO.Column
dbColumn.Name = "'" & ds.Tables(0).Columns(aa).Caption & "'"
dbColumn.Datatype = "VARCHAR(1000)"
dbColumn.AllowNulls = False
dbTable.Columns.Add(dbColumn)
pgBar.Value += 1 'progressbar
Next
sqlServer.Databases.Item("sitelist").Tables.Add(db Table)

ds = dataset

The database is created but the table won't.

The exception error tells me only how the column definition should be, and
as far as I know I have it right...

thanks,
Eric



Cor
Guest
 
Posts: n/a
#2: Nov 20 '05

re: Need some help with this code...


Hi EMW,

The question from the ds is not that difficult,
ds = dataset is not possible, it is strange you did not get an errormessage
in your IDE for that (dataset is a type), you can do

ds = new dataset (but than your ds is cleaned and looking of the sequence of
your code I think you don't want to do that)

I did look at the rest of your code, but I know to few from a full text
search from a SQL server to help you.

I think you have a better change for an answer the
public.dotnet.framework.adonet newsgroup or in a special SQL newsgroup.

I hope this did help so far?

Cor

[color=blue]
> Can someone please look at this code and tell me why I get an exception
> error on the last line:
>
> For aa = 0 To ds.Tables(0).Columns.Count - 1
> dbColumn = New SQLDMO.Column
> dbColumn.Name = "'" & ds.Tables(0).Columns(aa).Caption & "'"
> dbColumn.Datatype = "VARCHAR(1000)"
> dbColumn.AllowNulls = False
> dbTable.Columns.Add(dbColumn)
> pgBar.Value += 1 'progressbar
> Next
> sqlServer.Databases.Item("sitelist").Tables.Add(db Table)
>
> ds = dataset
>
> The database is created but the table won't.
>
> The exception error tells me only how the column definition should be, and
> as far as I know I have it right...
>[/color]


Cor
Guest
 
Posts: n/a
#3: Nov 20 '05

re: Need some help with this code...


Hi EMW,

The question from the ds is not that difficult,
ds = dataset is not possible, it is strange you did not get an errormessage
in your IDE for that (dataset is a type), you can do

ds = new dataset (but than your ds is cleaned and looking of the sequence of
your code I think you don't want to do that)

I did look at the rest of your code, but I know to few from a full text
search from a SQL server to help you.

I think you have a better change for an answer the
public.dotnet.framework.adonet newsgroup or in a special SQL newsgroup.

I hope this did help so far?

Cor

[color=blue]
> Can someone please look at this code and tell me why I get an exception
> error on the last line:
>
> For aa = 0 To ds.Tables(0).Columns.Count - 1
> dbColumn = New SQLDMO.Column
> dbColumn.Name = "'" & ds.Tables(0).Columns(aa).Caption & "'"
> dbColumn.Datatype = "VARCHAR(1000)"
> dbColumn.AllowNulls = False
> dbTable.Columns.Add(dbColumn)
> pgBar.Value += 1 'progressbar
> Next
> sqlServer.Databases.Item("sitelist").Tables.Add(db Table)
>
> ds = dataset
>
> The database is created but the table won't.
>
> The exception error tells me only how the column definition should be, and
> as far as I know I have it right...
>[/color]


EMW
Guest
 
Posts: n/a
#4: Nov 20 '05

re: Need some help with this code...


Not really ;)

The line ds=dataset is a comment by me for the ones reading this code...I
guess I should have put it different...

Thanks, though.
Eric.

"Cor" <non@non.com> schreef in bericht
news:OjhT5$ZsDHA.1196@TK2MSFTNGP12.phx.gbl...[color=blue]
> Hi EMW,
>
> The question from the ds is not that difficult,
> ds = dataset is not possible, it is strange you did not get an[/color]
errormessage[color=blue]
> in your IDE for that (dataset is a type), you can do
>
> ds = new dataset (but than your ds is cleaned and looking of the sequence[/color]
of[color=blue]
> your code I think you don't want to do that)
>
> I did look at the rest of your code, but I know to few from a full text
> search from a SQL server to help you.
>
> I think you have a better change for an answer the
> public.dotnet.framework.adonet newsgroup or in a special SQL newsgroup.
>
> I hope this did help so far?
>
> Cor
>
>[color=green]
> > Can someone please look at this code and tell me why I get an exception
> > error on the last line:
> >
> > For aa = 0 To ds.Tables(0).Columns.Count - 1
> > dbColumn = New SQLDMO.Column
> > dbColumn.Name = "'" & ds.Tables(0).Columns(aa).Caption & "'"
> > dbColumn.Datatype = "VARCHAR(1000)"
> > dbColumn.AllowNulls = False
> > dbTable.Columns.Add(dbColumn)
> > pgBar.Value += 1 'progressbar
> > Next
> > sqlServer.Databases.Item("sitelist").Tables.Add(db Table)
> >
> > ds = dataset
> >
> > The database is created but the table won't.
> >
> > The exception error tells me only how the column definition should be,[/color][/color]
and[color=blue][color=green]
> > as far as I know I have it right...
> >[/color]
>
>[/color]


EMW
Guest
 
Posts: n/a
#5: Nov 20 '05

re: Need some help with this code...


Not really ;)

The line ds=dataset is a comment by me for the ones reading this code...I
guess I should have put it different...

Thanks, though.
Eric.

"Cor" <non@non.com> schreef in bericht
news:OjhT5$ZsDHA.1196@TK2MSFTNGP12.phx.gbl...[color=blue]
> Hi EMW,
>
> The question from the ds is not that difficult,
> ds = dataset is not possible, it is strange you did not get an[/color]
errormessage[color=blue]
> in your IDE for that (dataset is a type), you can do
>
> ds = new dataset (but than your ds is cleaned and looking of the sequence[/color]
of[color=blue]
> your code I think you don't want to do that)
>
> I did look at the rest of your code, but I know to few from a full text
> search from a SQL server to help you.
>
> I think you have a better change for an answer the
> public.dotnet.framework.adonet newsgroup or in a special SQL newsgroup.
>
> I hope this did help so far?
>
> Cor
>
>[color=green]
> > Can someone please look at this code and tell me why I get an exception
> > error on the last line:
> >
> > For aa = 0 To ds.Tables(0).Columns.Count - 1
> > dbColumn = New SQLDMO.Column
> > dbColumn.Name = "'" & ds.Tables(0).Columns(aa).Caption & "'"
> > dbColumn.Datatype = "VARCHAR(1000)"
> > dbColumn.AllowNulls = False
> > dbTable.Columns.Add(dbColumn)
> > pgBar.Value += 1 'progressbar
> > Next
> > sqlServer.Databases.Item("sitelist").Tables.Add(db Table)
> >
> > ds = dataset
> >
> > The database is created but the table won't.
> >
> > The exception error tells me only how the column definition should be,[/color][/color]
and[color=blue][color=green]
> > as far as I know I have it right...
> >[/color]
>
>[/color]


One Handed Man
Guest
 
Posts: n/a
#6: Nov 20 '05

re: Need some help with this code...


See my comments below.

OHM


EMW wrote:[color=blue]
> Hi,
>
> Can someone please look at this code and tell me why I get an
> exception error on the last line:
>
> For aa = 0 To ds.Tables(0).Columns.Count - 1
> dbColumn = New SQLDMO.Column
> dbColumn.Name = "'" & ds.Tables(0).Columns(aa).Caption & "'"
> dbColumn.Datatype = "VARCHAR(1000)"
> dbColumn.AllowNulls = False
> dbTable.Columns.Add(dbColumn)
> pgBar.Value += 1 'progressbar
> Next
> sqlServer.Databases.Item("sitelist").Tables.Add(db Table)
>
> ds = dataset
>
> The database is created but the table won't.[/color]
The table wont what ??
[color=blue]
>
> The exception error tells me only how the column definition should
> be, and as far as I know I have it right...
>
> thanks,
> Eric[/color]

1.) When you say the last line do you mean '
sqlServer.Databases.Item("sitelist").Tables.Add(db Table) '

2.) I assume that the table has been newly created and did not contain any
information in it ?

3.) if you do a ex.ToString() at the point of exception, what is the
complete dump ?

If this doesent help, post the relevent or complete if its not too big (
project ( zipped up )

OHM










Closed Thread