PC Review


Reply
Thread Tools Rate Thread

Best practices to update SQL server database schema for new application version?

 
 
Hans Merkl
Guest
Posts: n/a
 
      1st Feb 2005
Hi,

I have a C# application that uses a SQL server database. I am ready to roll
out an update, but this update needs some additional fields and changed
default values for some tables together.
With Access and DAO this was easy to do because you had direct access to
the database structure via TableDef and QueryDef objects. I have done some
research but I can't find the equivalent functionality in ADO.NET.
Can anybody point me to information how to handle the following scenarios:

- Check if a field exists. If yes, change its data type and update the
existing values.
- Check if a field exists. If no, create it.

Every help is appreciated.

Hans Merkl






 
Reply With Quote
 
 
 
 
NuTcAsE
Guest
Posts: n/a
 
      1st Feb 2005
What you need is to get the schema of the table from the database. You
can use the FillSchema function on the SqlDataAdapter to fill a
datatable with the schema information of the table. From that then you
can check the table to see if the desired columns are there... if they
are you can issue a query to modify the column.

http://msdn.microsoft.com/library/de...chematopic.asp

 
Reply With Quote
 
Hans Merkl
Guest
Posts: n/a
 
      2nd Feb 2005
On 1 Feb 2005 14:58:52 -0800, NuTcAsE wrote:

> What you need is to get the schema of the table from the database. You
> can use the FillSchema function on the SqlDataAdapter to fill a
> datatable with the schema information of the table. From that then you
> can check the table to see if the desired columns are there... if they
> are you can issue a query to modify the column.
>
> http://msdn.microsoft.com/library/de...chematopic.asp


Thanks a lot. I'll check it out.

Hans
 
Reply With Quote
 
Hans Merkl
Guest
Posts: n/a
 
      4th Feb 2005
On Wed, 2 Feb 2005 11:32:52 -0500, Hans Merkl wrote:

> On 1 Feb 2005 14:58:52 -0800, NuTcAsE wrote:
>
>> What you need is to get the schema of the table from the database. You
>> can use the FillSchema function on the SqlDataAdapter to fill a
>> datatable with the schema information of the table. From that then you
>> can check the table to see if the desired columns are there... if they
>> are you can issue a query to modify the column.
>>
>> http://msdn.microsoft.com/library/de...chematopic.asp

>
> Thanks a lot. I'll check it out.
>
> Hans


Just in case other people haqve the same problem:

OleDbConnection.GetOleDbSchemaTable retrieves a good amount of info. It's
more than FillSchema provides. Of course you have to use OleDB for this to
work.
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
using XSD Database Schema for database creation and update WM Developer Microsoft Dot NET Compact Framework 0 20th Sep 2008 12:18 AM
Can I sync a typed dataset schema with database schema easily? John Microsoft Dot NET 1 2nd Jan 2008 10:37 AM
Copy database schema from Access to SQL Server schneider@rehm.de Microsoft ADO .NET 7 29th Oct 2007 07:51 AM
FYI: R2 schema update and version identification Jorge de Almeida Pinto [MVP] Microsoft Windows 2000 Active Directory 0 6th May 2006 03:09 PM
Best practice on local database Schema update RS Microsoft VB .NET 4 7th Sep 2005 08:38 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:43 AM.