Question : updating sql database structure while keeping existing structure intact

we have an application that we have been developing over the last few years.

as it has grown, the fields needed in the database behind it have grown.

updating old, original clients with new code has become a RPITA because they need the new fields in the database.

I know, I know, they should have generated scripts and applied them as they changed the database, but that wasnt done.

what i was HOPING for was some way to
1. keep the existing data
2. have some kind of function that attempts to update entire tables with new fields, but leaving existing fields in place.
3. have this function be dynamic, in other words,   client 1 may need a table updated with 8 new fields, while client 2 would only need 3 of those fields updated.  
4. needs to work in sql 2000-2008

hoping for something like alter table

but with a resume next kind of thing if the field already exists.

Answer : updating sql database structure while keeping existing structure intact

One way would be to set the global object. This can cause a timing issue if your global JS variable is not available before this code runs. This is good for an example though.

Page.ClientScript.RegisterClientScriptBlock(Me.GetType(), "script", _
        String.Format("setFrmServerCode={0}","SomeValueAsString")

So a second solution might be to create and set the global variable all at once from code behind. It will then be available for all your JS calls from then on.

Page.ClientScript.RegisterClientScriptBlock(Me.GetType(), "script", _
        String.Format("var setFrmServerCode={0}","SomeValueAsString")

Another would be to create a function that sets the object and use an event like <body onload> to call the event. This way lets you control the timing and make sure your global variable is available before you try to set it.

Page.ClientScript.RegisterClientScriptBlock(Me.GetType(), "script", _
        String.Format("function setGlobal(){{ setFrmServerCode= {0};}}","VariableDataAsString")

I've used all of these methods many times in the past with good success. I didn't convert them to C# as I already had these samples laying around. Hopefully you can see what to do and convert them yourself. If necessary I will convert them for you.
Random Solutions  
 
programming4us programming4us