Home All Groups Group Topic Archive Search About

Getting and updating columns in database

Author
4 May 2007 4:11 PM
Sid Price
I have an application that has already been deployed and we need to add a
new column to some of the tables in the application database. We are using
an access database. We have a solution working that basically opens a
dataset for each of the tables that needs updating, this dataset selects all
rows with the new column and the exception that arises when the column dies
not exist is caught and dealt with. It works fine with one exception and
that is that when the database has the column and a load of data in it
reading the dataset takes a long time.

'

' Iterate through the data tables

'

For Each oTableRow In oTableNames.Tables("Tables").Rows

Dim strTableName As String

strTableName = oTableRow("TableName")

oDatabase.Progress("Processing " & strTableName & " ...")

'

' Check if the tables has a "Comment" column, if not add it

'

Try

oTableRecords = oDatabase.GetDataset("SELECT Comment FROM " & strTableName,
"TableRecords")

Catch ex As Exception

'

' "Comment" not found, add it to this table

'

End try

Is there a way to check if the tables in the database have the required
column with using a select query to attempt to read those columns?


Thanks,
Sid.

Author
4 May 2007 5:04 PM
Kerry Moorman
Sid,

You might try a select statement that does not return any data:

"SELECT Comment FROM " & strTableName & " Where 1 = 0"

Kerry Moorman


Show quoteHide quote
"Sid Price" wrote:

> I have an application that has already been deployed and we need to add a
> new column to some of the tables in the application database. We are using
> an access database. We have a solution working that basically opens a
> dataset for each of the tables that needs updating, this dataset selects all
> rows with the new column and the exception that arises when the column dies
> not exist is caught and dealt with. It works fine with one exception and
> that is that when the database has the column and a load of data in it
> reading the dataset takes a long time.
>
> '
>
> ' Iterate through the data tables
>
> '
>
> For Each oTableRow In oTableNames.Tables("Tables").Rows
>
> Dim strTableName As String
>
> strTableName = oTableRow("TableName")
>
> oDatabase.Progress("Processing " & strTableName & " ...")
>
> '
>
> ' Check if the tables has a "Comment" column, if not add it
>
> '
>
> Try
>
> oTableRecords = oDatabase.GetDataset("SELECT Comment FROM " & strTableName,
> "TableRecords")
>
> Catch ex As Exception
>
> '
>
> ' "Comment" not found, add it to this table
>
> '
>
> End try
>
> Is there a way to check if the tables in the database have the required
> column with using a select query to attempt to read those columns?
>
>
> Thanks,
> Sid.
>
>
>
Author
4 May 2007 7:41 PM
Sid Price
Thank you, that did indeed speed things up enormously,
Sid.

Show quoteHide quote
"Kerry Moorman" <KerryMoor***@discussions.microsoft.com> wrote in message
news:E61C5BF8-1716-42B8-B283-69883AA4D7D4@microsoft.com...
> Sid,
>
> You might try a select statement that does not return any data:
>
> "SELECT Comment FROM " & strTableName & " Where 1 = 0"
>
> Kerry Moorman
>
>
> "Sid Price" wrote:
>
>> I have an application that has already been deployed and we need to add a
>> new column to some of the tables in the application database. We are
>> using
>> an access database. We have a solution working that basically opens a
>> dataset for each of the tables that needs updating, this dataset selects
>> all
>> rows with the new column and the exception that arises when the column
>> dies
>> not exist is caught and dealt with. It works fine with one exception and
>> that is that when the database has the column and a load of data in it
>> reading the dataset takes a long time.
>>
>> '
>>
>> ' Iterate through the data tables
>>
>> '
>>
>> For Each oTableRow In oTableNames.Tables("Tables").Rows
>>
>> Dim strTableName As String
>>
>> strTableName = oTableRow("TableName")
>>
>> oDatabase.Progress("Processing " & strTableName & " ...")
>>
>> '
>>
>> ' Check if the tables has a "Comment" column, if not add it
>>
>> '
>>
>> Try
>>
>> oTableRecords = oDatabase.GetDataset("SELECT Comment FROM " &
>> strTableName,
>> "TableRecords")
>>
>> Catch ex As Exception
>>
>> '
>>
>> ' "Comment" not found, add it to this table
>>
>> '
>>
>> End try
>>
>> Is there a way to check if the tables in the database have the required
>> column with using a select query to attempt to read those columns?
>>
>>
>> Thanks,
>> Sid.
>>
>>
>>