PC Review


Reply
Thread Tools Rate Thread

Creating new field while app running

 
 
John
Guest
Posts: n/a
 
      14th Aug 2005
Hi

Is it possible to add a field to an sql server 20005 table programmatically
by a vb.net app while the vb.net app has the table being viewed on a vb.net
form?

Thanks

Regards


 
Reply With Quote
 
 
 
 
=?iso-8859-1?B?Sulq6Q==?=
Guest
Posts: n/a
 
      14th Aug 2005
you can, if you use dataset for example, then your program retrieve the data
then close the connection. so there is no lock when you'll add a field.

also, adding a field is a transaction like any other transaction in the
database, so when the table become available, the field will be added


"John" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hi
>
> Is it possible to add a field to an sql server 20005 table
> programmatically by a vb.net app while the vb.net app has the table being
> viewed on a vb.net form?
>
> Thanks
>
> Regards
>
>


 
Reply With Quote
 
Cor Ligthert [MVP]
Guest
Posts: n/a
 
      14th Aug 2005
John,

You can, however it is probably not a good idea.

You can do that with SQL "Alter" commands and use the Adonet command
(SQLClient.SQLCommand) ExecuteNonQuery

You have crossposted to more newsgroups, did you know that the real
newsgroup for your question is

microsoft.public.dotnet.framework.adonet

I hope this helps,

Cor


 
Reply With Quote
 
m.posseth
Guest
Posts: n/a
 
      14th Aug 2005
or maybe

microsoft.public.sqlserver.programming ???? ( as there are more ways to
perform this as with ADO.Net )


ofcourse it is always the est in a managed situation to let the DBA perform
these tasks , as changing columns might also add the need of performance
analyzing of the database and take apropriate actions that might affect the
database in a possitive way ( adding deleting indexes , constrains etc etc )

if your program is also responsible for the managing task ( like a user
level deployed MSDE database ) it is a good idea in my opinion to do the
following


perform the wanted tasks on a sql server ,with enterprise manager , optimize
the database, now export all your changes as SQL files

you can now import these files in your deployed sql instances either with a
shell call to the command line tools or just read them in and execute the
statements on the connection object ( ofcourse you need to log in with SA ,
administrator rights to do that , or with a pre defined user that was
granted the apropriate rights on the database to perform these actions )


regards

Michel Posseth





"Cor Ligthert [MVP]" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> John,
>
> You can, however it is probably not a good idea.
>
> You can do that with SQL "Alter" commands and use the Adonet command
> (SQLClient.SQLCommand) ExecuteNonQuery
>
> You have crossposted to more newsgroups, did you know that the real
> newsgroup for your question is
>
> microsoft.public.dotnet.framework.adonet
>
> I hope this helps,
>
> Cor
>



 
Reply With Quote
 
Erland Sommarskog
Guest
Posts: n/a
 
      14th Aug 2005
John ((E-Mail Removed)) writes:
> Is it possible to add a field to an sql server 20005 table
> programmatically by a vb.net app while the vb.net app has the table
> being viewed on a vb.net form?


Well, depends on what you mean with possible. But since ADO .Net is
disconnected, there are no locks on the table preventing columns to
be added by you or anyone else.

What you will happen to your VB app next time it access the table
I don't know. Since, a table is intended to be a static entity which
changes only on application upgrades, it's not that your dataset is
going to change automatically. There may be methods to add columns,
though.

Anyway, unless this is a temp table you are working with, you are
probably off-track here. Describe you real business problem, and you
may get better approaches to solve that problem.

--
Erland Sommarskog, SQL Server MVP, (E-Mail Removed)

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp

 
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
Pivot Table question: Creating a new field that calculates thedivision of one data field by another Mike C Microsoft Excel Discussion 4 13th Jul 2009 08:15 PM
Creating a Calculated Field From a Running Total Field Joe Microsoft Excel Worksheet Functions 1 4th Sep 2008 03:24 PM
Query Help.. Creating a running Total Field????? Darryn Ross Microsoft Access Queries 8 28th Oct 2004 07:54 AM
Creating a multiselect field in a form to populate a single field in a table Conni Microsoft Access Forms 1 21st Sep 2004 05:58 PM
Creating a running total - using "x" to populate field Bobbiec Microsoft Excel Worksheet Functions 4 25th Jul 2003 08:16 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:23 AM.