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 & "'" 'ds is
the dataset
dbColumn.Datatype = "VARCHAR(1000)"
dbColumn.AllowNulls = False
dbTable.Columns.Add(dbColumn)
pgBar.Value += 1 'progressbar
Next
sqlServer.Databases.Item("sitelist").Tables.Add(dbTable) 'On this line
I get an exception error.


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

Re: I need some help with this code.... by EMW

EMW
Sun Nov 23 13:30:51 CST 2003

Found it!

it was the VARCHAR(1000) it should have been VARCHAR en the length of the
column should be set on a number



"EMW" <someone@microsoft.com> schreef in bericht
news:3fc0e4f4$0$36109$5fc3050@dreader2.news.tiscali.nl...
> 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 & "'" 'ds
is
> the dataset
> dbColumn.Datatype = "VARCHAR(1000)"
> dbColumn.AllowNulls = False
> dbTable.Columns.Add(dbColumn)
> pgBar.Value += 1 'progressbar
> Next
> sqlServer.Databases.Item("sitelist").Tables.Add(dbTable) 'On this
line
> I get an exception error.
>
>
> 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
>
>
>
>