Need some help with this code...

  • Thread starter Thread starter EMW
  • Start date Start date
E

EMW

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(dbTable)

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
 
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
 
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.
 
See my comments below.

OHM

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(dbTable)

ds = dataset

The database is created but the table won't.
The table wont what ??
The exception error tells me only how the column definition should
be, and as far as I know I have it right...

thanks,
Eric

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

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
 
Back
Top